JUCE
Classes | Public Member Functions | Public Attributes | List of all members
AudioProcessorValueTreeState Class Reference

This class contains a ValueTree which is used to manage an AudioProcessor's entire state. More...

+ Inheritance diagram for AudioProcessorValueTreeState:

Classes

class  ButtonAttachment
 An object of this class maintains a connection between a Button and a parameter in an AudioProcessorValueTreeState. More...
 
class  ComboBoxAttachment
 An object of this class maintains a connection between a ComboBox and a parameter in an AudioProcessorValueTreeState. More...
 
struct  Listener
 A listener class that can be attached to an AudioProcessorValueTreeState. More...
 
class  SliderAttachment
 An object of this class maintains a connection between a Slider and a parameter in an AudioProcessorValueTreeState. More...
 

Public Member Functions

 AudioProcessorValueTreeState (AudioProcessor &processorToConnectTo, UndoManager *undoManagerToUse)
 Creates a state object for a given processor. More...
 
 ~AudioProcessorValueTreeState ()
 Destructor. More...
 
AudioProcessorParametercreateAndAddParameter (String parameterID, String parameterName, String labelText, NormalisableRange< float > valueRange, float defaultValue, std::function< String(float)> valueToTextFunction, std::function< float(const String &)> textToValueFunction)
 Creates and returns a new parameter object for controlling a parameter with the given ID. More...
 
AudioProcessorParametergetParameter (StringRef parameterID) const noexcept
 Returns a parameter by its ID string. More...
 
float * getRawParameterValue (StringRef parameterID) const noexcept
 Returns a pointer to a floating point representation of a particular parameter which a realtime process can read to find out its current value. More...
 
void addParameterListener (StringRef parameterID, Listener *listener)
 Attaches a callback to one of the parameters, which will be called when the parameter changes. More...
 
void removeParameterListener (StringRef parameterID, Listener *listener)
 Removes a callback that was previously added with addParameterCallback(). More...
 
Value getParameterAsValue (StringRef parameterID) const
 Returns a Value object that can be used to control a particular parameter. More...
 
NormalisableRange< float > getParameterRange (StringRef parameterID) const noexcept
 Returns the range that was set when the given parameter was created. More...
 

Public Attributes

AudioProcessorprocessor
 A reference to the processor with which this state is associated. More...
 
ValueTree state
 The state of the whole processor. More...
 
UndoManager *const undoManager
 Provides access to the undo manager that this object is using. More...
 

Detailed Description

This class contains a ValueTree which is used to manage an AudioProcessor's entire state.

It has its own internal class of parameter object which are linked to values within its ValueTree, and which are each identified by a string ID.

To use: Create a AudioProcessorValueTreeState, and give it some parameters using createParameter().

You can get access to the underlying ValueTree object via the state member variable, so you can add extra properties to it as necessary.

It also provides some utility child classes for connecting parameters directly to GUI controls like sliders.

Constructor & Destructor Documentation

AudioProcessorValueTreeState::AudioProcessorValueTreeState ( AudioProcessor processorToConnectTo,
UndoManager undoManagerToUse 
)

Creates a state object for a given processor.

The UndoManager is optional and can be a nullptr. After creating your state object, you should add parameters with the createAndAddParameter() method. Note that each AudioProcessorValueTreeState should be attached to only one processor, and must have the same lifetime as the processor, as they will have dependencies on each other.

AudioProcessorValueTreeState::~AudioProcessorValueTreeState ( )

Destructor.

Member Function Documentation

AudioProcessorParameter* AudioProcessorValueTreeState::createAndAddParameter ( String  parameterID,
String  parameterName,
String  labelText,
NormalisableRange< float >  valueRange,
float  defaultValue,
std::function< String(float)>  valueToTextFunction,
std::function< float(const String &)>  textToValueFunction 
)

Creates and returns a new parameter object for controlling a parameter with the given ID.

Calling this will create and add a special type of AudioProcessorParameter to the AudioProcessor to which this state is attached.

Parameters
parameterIDA unique string ID for the new parameter
parameterNameThe name that the parameter will return from AudioProcessorParameter::getName()
labelTextThe label that the parameter will return from AudioProcessorParameter::getLabel()
valueRangeA mapping that will be used to determine the value range which this parameter uses
defaultValueA default value for the parameter (in non-normalised units)
valueToTextFunctionA function that will convert a non-normalised value to a string for the AudioProcessorParameter::getText() method. This can be nullptr to use the default implementation
textToValueFunctionThe inverse of valueToTextFunction
Returns
the parameter object that was created
AudioProcessorParameter* AudioProcessorValueTreeState::getParameter ( StringRef  parameterID) const
noexcept

Returns a parameter by its ID string.

float* AudioProcessorValueTreeState::getRawParameterValue ( StringRef  parameterID) const
noexcept

Returns a pointer to a floating point representation of a particular parameter which a realtime process can read to find out its current value.

void AudioProcessorValueTreeState::addParameterListener ( StringRef  parameterID,
Listener listener 
)

Attaches a callback to one of the parameters, which will be called when the parameter changes.

void AudioProcessorValueTreeState::removeParameterListener ( StringRef  parameterID,
Listener listener 
)

Removes a callback that was previously added with addParameterCallback().

Value AudioProcessorValueTreeState::getParameterAsValue ( StringRef  parameterID) const

Returns a Value object that can be used to control a particular parameter.

NormalisableRange<float> AudioProcessorValueTreeState::getParameterRange ( StringRef  parameterID) const
noexcept

Returns the range that was set when the given parameter was created.

Member Data Documentation

AudioProcessor& AudioProcessorValueTreeState::processor

A reference to the processor with which this state is associated.

ValueTree AudioProcessorValueTreeState::state

The state of the whole processor.

You can replace this with your own ValueTree object, and can add properties and children to the tree. This class will automatically add children for each of the parameter objects that are created by createParameter().

UndoManager* const AudioProcessorValueTreeState::undoManager

Provides access to the undo manager that this object is using.


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