VCV Rack API v2
Loading...
Searching...
No Matches
rack::engine::ParamQuantity Struct Reference
module NULL

A Quantity that wraps an engine::Param. More...

#include <ParamQuantity.hpp>

Inheritance diagram for rack::engine::ParamQuantity:
[legend]
Collaboration diagram for rack::engine::ParamQuantity:
[legend]

Public Member Functions

ParamgetParam ()
 
void setValue (float value) override
 Sets the target value of the Engine's smoothing algorithm, or immediate value if smoothing is disabled.
 
float getValue () override
 Gets the Param's smoothing target value, or immediate value if smoothing is disabled.
 
void setImmediateValue (float value)
 Sets the Param's value immediately without smoothing.
 
float getImmediateValue ()
 Gets the Param's value post-smoothing.
 
float getMinValue () override
 Returns the minimum recommended value.
 
float getMaxValue () override
 Returns the maximum recommended value.
 
float getDefaultValue () override
 Returns the default value, for resetting.
 
float getDisplayValue () override
 Returns the value, transformed for displaying.
 
void setDisplayValue (float displayValue) override
 Always sets immediate value.
 
std::string getDisplayValueString () override
 Returns a string representation of the display value.
 
void setDisplayValueString (std::string s) override
 Always sets immediate value.
 
int getDisplayPrecision () override
 The number of total decimal places for generating the display value string.
 
std::string getLabel () override
 The name of the quantity.
 
std::string getUnit () override
 The unit abbreviation of the quantity.
 
void reset () override
 Resets the value to the default value.
 
void randomize () override
 Sets the value to a uniform random value between the bounds.
 
virtual std::string getDescription ()
 
virtual json_t * toJson ()
 
virtual void fromJson (json_t *rootJ)
 
DEPRECATED void setSmoothValue (float value)
 Deprecated.
 
DEPRECATED float getSmoothValue ()
 Deprecated.
 
- Public Member Functions inherited from rack::Quantity
virtual ~Quantity ()
 
virtual std::string getString ()
 Returns a string representation of the quantity.
 
bool isMin ()
 Checks whether the value is at the min value.
 
bool isMax ()
 Checks whether the value is at the max value.
 
void setMin ()
 Sets the value to the min value.
 
void setMax ()
 Sets the value to the max value.
 
void toggle ()
 Sets the value to max if the current value is min, otherwise sets the value to min.
 
void moveValue (float deltaValue)
 Adds an amount to the value.
 
float getRange ()
 The difference between the max and min values.
 
bool isBounded ()
 Checks whether the bounds are finite.
 
float toScaled (float value)
 Transforms a value to the range 0 to 1.
 
float fromScaled (float scaledValue)
 Transforms a value from the range 0 to 1.
 
void setScaledValue (float scaledValue)
 Sets value from the range 0 to 1.
 
float getScaledValue ()
 Returns the value scaled to the range 0 to 1.
 
void moveScaledValue (float deltaScaledValue)
 Adds an amount to the value scaled to the range 0 to 1.
 

Public Attributes

int paramId = -1
 
float minValue = 0.f
 The minimum allowed value.
 
float maxValue = 1.f
 The maximum allowed value.
 
float defaultValue = 0.f
 The initial value.
 
std::string name
 The name of the parameter, using sentence capitalization.
 
std::string unit
 The numerical unit of measurement appended to the value.
 
float displayBase = 0.f
 Set to 0 for linear, positive for exponential, negative for logarithmic.
 
float displayMultiplier = 1.f
 
float displayOffset = 0.f
 
int displayPrecision = 5
 Number of digits of precision to display.
 
std::string description
 An optional one-sentence description of the parameter.
 
bool resetEnabled = true
 Enables parameter resetting when the module or parameter itself is reset.
 
bool randomizeEnabled = true
 Enables parameter randomization when the module is randomized.
 
bool smoothEnabled = false
 Enables per-sample Engine parameter smoothing when setSmoothValue() is called.
 
bool snapEnabled = false
 Rounds values to the nearest integer.
 

Detailed Description

A Quantity that wraps an engine::Param.

If smoothEnabled is true, all methods access/modify the Param's target value of the Engine's per-sample smoothing algorithm instead of the immediate value.

Member Function Documentation

◆ getParam()

Param * rack::engine::ParamQuantity::getParam ( )

◆ setValue()

void rack::engine::ParamQuantity::setValue ( float value)
overridevirtual

Sets the target value of the Engine's smoothing algorithm, or immediate value if smoothing is disabled.

Before Rack 2.3.0, this always set the Param's immediate value. For this behavior, use setImmediateValue() instead.

Reimplemented from rack::Quantity.

◆ getValue()

float rack::engine::ParamQuantity::getValue ( )
overridevirtual

Gets the Param's smoothing target value, or immediate value if smoothing is disabled.

Before Rack 2.3.0, this always got the Param's immediate value. For this behavior, use getImmediateValue() instead.

Reimplemented from rack::Quantity.

◆ setImmediateValue()

void rack::engine::ParamQuantity::setImmediateValue ( float value)

Sets the Param's value immediately without smoothing.

If the Param's value is currently being smoothed by the Engine, smoothing is canceled.

◆ getImmediateValue()

float rack::engine::ParamQuantity::getImmediateValue ( )

Gets the Param's value post-smoothing.

If (and only if) the Param's value is currently being smoothed by the Engine, the return value is different than getValue().

◆ getMinValue()

float rack::engine::ParamQuantity::getMinValue ( )
overridevirtual

Returns the minimum recommended value.

Reimplemented from rack::Quantity.

◆ getMaxValue()

float rack::engine::ParamQuantity::getMaxValue ( )
overridevirtual

Returns the maximum recommended value.

Reimplemented from rack::Quantity.

◆ getDefaultValue()

float rack::engine::ParamQuantity::getDefaultValue ( )
overridevirtual

Returns the default value, for resetting.

Reimplemented from rack::Quantity.

◆ getDisplayValue()

float rack::engine::ParamQuantity::getDisplayValue ( )
overridevirtual

Returns the value, transformed for displaying.

Useful for logarithmic scaling, multiplying by 100 for percentages, etc.

Reimplemented from rack::Quantity.

◆ setDisplayValue()

void rack::engine::ParamQuantity::setDisplayValue ( float displayValue)
overridevirtual

Always sets immediate value.

Reimplemented from rack::Quantity.

◆ getDisplayValueString()

std::string rack::engine::ParamQuantity::getDisplayValueString ( )
overridevirtual

Returns a string representation of the display value.

Reimplemented from rack::Quantity.

Reimplemented in rack::engine::SwitchQuantity.

◆ setDisplayValueString()

void rack::engine::ParamQuantity::setDisplayValueString ( std::string s)
overridevirtual

Always sets immediate value.

Reimplemented from rack::Quantity.

Reimplemented in rack::engine::SwitchQuantity.

◆ getDisplayPrecision()

int rack::engine::ParamQuantity::getDisplayPrecision ( )
overridevirtual

The number of total decimal places for generating the display value string.

Reimplemented from rack::Quantity.

◆ getLabel()

std::string rack::engine::ParamQuantity::getLabel ( )
overridevirtual

The name of the quantity.

Reimplemented from rack::Quantity.

◆ getUnit()

std::string rack::engine::ParamQuantity::getUnit ( )
overridevirtual

The unit abbreviation of the quantity.

Include an initial space character if you want a space after the number, e.g. "440 Hz". This allows space-less units, like "100%".

Reimplemented from rack::Quantity.

◆ reset()

void rack::engine::ParamQuantity::reset ( )
overridevirtual

Resets the value to the default value.

Reimplemented from rack::Quantity.

◆ randomize()

void rack::engine::ParamQuantity::randomize ( )
overridevirtual

Sets the value to a uniform random value between the bounds.

Reimplemented from rack::Quantity.

◆ getDescription()

virtual std::string rack::engine::ParamQuantity::getDescription ( )
virtual

◆ toJson()

virtual json_t * rack::engine::ParamQuantity::toJson ( )
virtual

◆ fromJson()

virtual void rack::engine::ParamQuantity::fromJson ( json_t * rootJ)
virtual

◆ setSmoothValue()

DEPRECATED void rack::engine::ParamQuantity::setSmoothValue ( float value)

Deprecated.

Use setValue() instead, which is identical since Rack 2.3.0.

◆ getSmoothValue()

DEPRECATED float rack::engine::ParamQuantity::getSmoothValue ( )

Deprecated.

Use getValue() instead, which is identical since Rack 2.3.0.

Member Data Documentation

◆ paramId

int rack::engine::ParamQuantity::paramId = -1

◆ minValue

float rack::engine::ParamQuantity::minValue = 0.f

The minimum allowed value.

◆ maxValue

float rack::engine::ParamQuantity::maxValue = 1.f

The maximum allowed value.

Must be greater than minValue.

◆ defaultValue

float rack::engine::ParamQuantity::defaultValue = 0.f

The initial value.

◆ name

std::string rack::engine::ParamQuantity::name

The name of the parameter, using sentence capitalization.

e.g. "Frequency", "Pulse width", "Alternative mode"

◆ unit

std::string rack::engine::ParamQuantity::unit

The numerical unit of measurement appended to the value.

Unit words and abbreviations should have a space to separate the numerical value from the number (e.g. " semitones", " V", " ms"). Unit symbols should have no space (e.g. "%", "ยบ").

◆ displayBase

float rack::engine::ParamQuantity::displayBase = 0.f

Set to 0 for linear, positive for exponential, negative for logarithmic.

The formula is \(displayValue = f(value) * displayMultiplier + displayOffset\) where \(f(value)\) is

  • \(value\) for \(displayBase = 0\).
  • \(\log_{-displayBase}(value)\) for \(displayBase < 0\).
  • \(displayBase^{value}\) for \(displayBase > 0\).

◆ displayMultiplier

float rack::engine::ParamQuantity::displayMultiplier = 1.f

◆ displayOffset

float rack::engine::ParamQuantity::displayOffset = 0.f

◆ displayPrecision

int rack::engine::ParamQuantity::displayPrecision = 5

Number of digits of precision to display.

With displayPrecision = 5 for example, numbers will print as 12.345, 0.12345, 1.2345e6, or 1.2345e-6.

◆ description

std::string rack::engine::ParamQuantity::description

An optional one-sentence description of the parameter.

◆ resetEnabled

bool rack::engine::ParamQuantity::resetEnabled = true

Enables parameter resetting when the module or parameter itself is reset.

◆ randomizeEnabled

bool rack::engine::ParamQuantity::randomizeEnabled = true

Enables parameter randomization when the module is randomized.

Unbounded (infinite) parameters are not randomizable, regardless of this setting.

◆ smoothEnabled

bool rack::engine::ParamQuantity::smoothEnabled = false

Enables per-sample Engine parameter smoothing when setSmoothValue() is called.

◆ snapEnabled

bool rack::engine::ParamQuantity::snapEnabled = false

Rounds values to the nearest integer.


The documentation for this struct was generated from the following file: