VCV Rack API v2
Loading...
Searching...
No Matches
rack::Quantity Struct Reference

A controller for manipulating a float value (which subclasses must store somehow) with limits and labels. More...

#include <Quantity.hpp>

Inheritance diagram for rack::Quantity:
[legend]

Public Member Functions

virtual ~Quantity ()
 
virtual void setValue (float value)
 Sets the value directly.
 
virtual float getValue ()
 Returns the value.
 
virtual float getMinValue ()
 Returns the minimum recommended value.
 
virtual float getMaxValue ()
 Returns the maximum recommended value.
 
virtual float getDefaultValue ()
 Returns the default value, for resetting.
 
virtual float getDisplayValue ()
 Returns the value, transformed for displaying.
 
virtual void setDisplayValue (float displayValue)
 Inversely transforms the display value and sets the value.
 
virtual int getDisplayPrecision ()
 The number of total decimal places for generating the display value string.
 
virtual std::string getDisplayValueString ()
 Returns a string representation of the display value.
 
virtual void setDisplayValueString (std::string s)
 Sets the value from a display string.
 
virtual std::string getLabel ()
 The name of the quantity.
 
virtual std::string getUnit ()
 The unit abbreviation of the quantity.
 
virtual std::string getString ()
 Returns a string representation of the quantity.
 
virtual void reset ()
 Resets the value to the default value.
 
virtual void randomize ()
 Sets the value to a uniform random value between the bounds.
 
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.
 

Detailed Description

A controller for manipulating a float value (which subclasses must store somehow) with limits and labels.

Often used as a decorator component for widget::Widgets that read or write a quantity.

Constructor & Destructor Documentation

◆ ~Quantity()

virtual rack::Quantity::~Quantity ( )
inlinevirtual

Member Function Documentation

◆ setValue()

virtual void rack::Quantity::setValue ( float value)
inlinevirtual

Sets the value directly.

Override this to change the state of your subclass to represent the new value.

Reimplemented in rack::engine::ParamQuantity.

◆ getValue()

virtual float rack::Quantity::getValue ( )
inlinevirtual

Returns the value.

Override this to return the state of your subclass.

Reimplemented in rack::engine::ParamQuantity.

◆ getMinValue()

virtual float rack::Quantity::getMinValue ( )
inlinevirtual

Returns the minimum recommended value.

Reimplemented in rack::engine::ParamQuantity.

◆ getMaxValue()

virtual float rack::Quantity::getMaxValue ( )
inlinevirtual

Returns the maximum recommended value.

Reimplemented in rack::engine::ParamQuantity.

◆ getDefaultValue()

virtual float rack::Quantity::getDefaultValue ( )
inlinevirtual

Returns the default value, for resetting.

Reimplemented in rack::engine::ParamQuantity.

◆ getDisplayValue()

virtual float rack::Quantity::getDisplayValue ( )
virtual

Returns the value, transformed for displaying.

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

Reimplemented in rack::engine::ParamQuantity.

◆ setDisplayValue()

virtual void rack::Quantity::setDisplayValue ( float displayValue)
virtual

Inversely transforms the display value and sets the value.

Reimplemented in rack::engine::ParamQuantity.

◆ getDisplayPrecision()

virtual int rack::Quantity::getDisplayPrecision ( )
virtual

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

Reimplemented in rack::engine::ParamQuantity.

◆ getDisplayValueString()

virtual std::string rack::Quantity::getDisplayValueString ( )
virtual

Returns a string representation of the display value.

Reimplemented in rack::engine::ParamQuantity, and rack::engine::SwitchQuantity.

◆ setDisplayValueString()

virtual void rack::Quantity::setDisplayValueString ( std::string s)
virtual

Sets the value from a display string.

Reimplemented in rack::engine::ParamQuantity, and rack::engine::SwitchQuantity.

◆ getLabel()

virtual std::string rack::Quantity::getLabel ( )
inlinevirtual

The name of the quantity.

Reimplemented in rack::engine::ParamQuantity.

◆ getUnit()

virtual std::string rack::Quantity::getUnit ( )
inlinevirtual

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 in rack::engine::ParamQuantity.

◆ getString()

virtual std::string rack::Quantity::getString ( )
virtual

Returns a string representation of the quantity.

◆ reset()

virtual void rack::Quantity::reset ( )
virtual

Resets the value to the default value.

Reimplemented in rack::engine::ParamQuantity.

◆ randomize()

virtual void rack::Quantity::randomize ( )
virtual

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

Reimplemented in rack::engine::ParamQuantity.

◆ isMin()

bool rack::Quantity::isMin ( )

Checks whether the value is at the min value.

◆ isMax()

bool rack::Quantity::isMax ( )

Checks whether the value is at the max value.

◆ setMin()

void rack::Quantity::setMin ( )

Sets the value to the min value.

◆ setMax()

void rack::Quantity::setMax ( )

Sets the value to the max value.

◆ toggle()

void rack::Quantity::toggle ( )

Sets the value to max if the current value is min, otherwise sets the value to min.

◆ moveValue()

void rack::Quantity::moveValue ( float deltaValue)

Adds an amount to the value.

◆ getRange()

float rack::Quantity::getRange ( )

The difference between the max and min values.

◆ isBounded()

bool rack::Quantity::isBounded ( )

Checks whether the bounds are finite.

◆ toScaled()

float rack::Quantity::toScaled ( float value)

Transforms a value to the range 0 to 1.

◆ fromScaled()

float rack::Quantity::fromScaled ( float scaledValue)

Transforms a value from the range 0 to 1.

◆ setScaledValue()

void rack::Quantity::setScaledValue ( float scaledValue)

Sets value from the range 0 to 1.

◆ getScaledValue()

float rack::Quantity::getScaledValue ( )

Returns the value scaled to the range 0 to 1.

◆ moveScaledValue()

void rack::Quantity::moveScaledValue ( float deltaScaledValue)

Adds an amount to the value scaled to the range 0 to 1.


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