VCV Rack API v2
Loading...
Searching...
No Matches
ParamQuantity.hpp
Go to the documentation of this file.
1#pragma once
2#include <vector>
3
4#include <jansson.h>
5
6#include <Quantity.hpp>
7#include <engine/Param.hpp>
8
9
10namespace rack {
11namespace engine {
12
13
14struct Module;
15
16
22 Module* module = NULL;
23 int paramId = -1;
24
26 float minValue = 0.f;
28 float maxValue = 1.f;
30 float defaultValue = 0.f;
31
35 std::string name;
40 std::string unit;
47 float displayBase = 0.f;
48 float displayMultiplier = 1.f;
49 float displayOffset = 0.f;
55 std::string description;
56
59 bool resetEnabled = true;
63 bool randomizeEnabled = true;
65 bool smoothEnabled = false;
67 bool snapEnabled = false;
68
70
76 void setValue(float value) override;
82 float getValue() override;
87 void setImmediateValue(float value);
93
94 float getMinValue() override;
95 float getMaxValue() override;
96 float getDefaultValue() override;
97 float getDisplayValue() override;
99 void setDisplayValue(float displayValue) override;
100 std::string getDisplayValueString() override;
102 void setDisplayValueString(std::string s) override;
103 int getDisplayPrecision() override;
104 std::string getLabel() override;
105 std::string getUnit() override;
106 void reset() override;
107 void randomize() override;
108
109 virtual std::string getDescription();
110
111 virtual json_t* toJson();
112 virtual void fromJson(json_t* rootJ);
113
115 DEPRECATED void setSmoothValue(float value);
118};
119
120
122 std::vector<std::string> labels;
123
124 std::string getDisplayValueString() override;
125 void setDisplayValueString(std::string s) override;
126};
127
128
129} // namespace engine
130} // namespace rack
#define DEPRECATED
Attribute for deprecated functions and symbols.
Definition common.hpp:26
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9
A controller for manipulating a float value (which subclasses must store somehow) with limits and lab...
Definition Quantity.hpp:14
DSP processor instance for your module.
Definition Module.hpp:29
A Quantity that wraps an engine::Param.
Definition ParamQuantity.hpp:21
float maxValue
The maximum allowed value.
Definition ParamQuantity.hpp:28
std::string name
The name of the parameter, using sentence capitalization.
Definition ParamQuantity.hpp:35
float displayMultiplier
Definition ParamQuantity.hpp:48
DEPRECATED float getSmoothValue()
Deprecated.
float getMaxValue() override
Returns the maximum recommended value.
bool snapEnabled
Rounds values to the nearest integer.
Definition ParamQuantity.hpp:67
float getImmediateValue()
Gets the Param's value post-smoothing.
std::string unit
The numerical unit of measurement appended to the value.
Definition ParamQuantity.hpp:40
float displayOffset
Definition ParamQuantity.hpp:49
std::string getLabel() override
The name of the quantity.
float getValue() override
Gets the Param's smoothing target value, or immediate value if smoothing is disabled.
std::string getUnit() override
The unit abbreviation of the quantity.
void setDisplayValue(float displayValue) override
Always sets immediate value.
DEPRECATED void setSmoothValue(float value)
Deprecated.
float minValue
The minimum allowed value.
Definition ParamQuantity.hpp:26
void setDisplayValueString(std::string s) override
Always sets immediate value.
float getDefaultValue() override
Returns the default value, for resetting.
void setValue(float value) override
Sets the target value of the Engine's smoothing algorithm, or immediate value if smoothing is disable...
void reset() override
Resets the value to the default value.
virtual std::string getDescription()
int displayPrecision
Number of digits of precision to display.
Definition ParamQuantity.hpp:53
std::string description
An optional one-sentence description of the parameter.
Definition ParamQuantity.hpp:55
bool randomizeEnabled
Enables parameter randomization when the module is randomized.
Definition ParamQuantity.hpp:63
virtual json_t * toJson()
int getDisplayPrecision() override
The number of total decimal places for generating the display value string.
bool smoothEnabled
Enables per-sample Engine parameter smoothing when setSmoothValue() is called.
Definition ParamQuantity.hpp:65
float defaultValue
The initial value.
Definition ParamQuantity.hpp:30
bool resetEnabled
Enables parameter resetting when the module or parameter itself is reset.
Definition ParamQuantity.hpp:59
float getMinValue() override
Returns the minimum recommended value.
void randomize() override
Sets the value to a uniform random value between the bounds.
int paramId
Definition ParamQuantity.hpp:23
float displayBase
Set to 0 for linear, positive for exponential, negative for logarithmic.
Definition ParamQuantity.hpp:47
std::string getDisplayValueString() override
Returns a string representation of the display value.
virtual void fromJson(json_t *rootJ)
void setImmediateValue(float value)
Sets the Param's value immediately without smoothing.
float getDisplayValue() override
Returns the value, transformed for displaying.
Definition Param.hpp:10
Definition ParamQuantity.hpp:121
std::vector< std::string > labels
Definition ParamQuantity.hpp:122
void setDisplayValueString(std::string s) override
Always sets immediate value.
std::string getDisplayValueString() override
Returns a string representation of the display value.