LMMS
Loading...
Searching...
No Matches
juce::AudioProcessorValueTreeState::Parameter Class Referencefinal

#include <juce_AudioProcessorValueTreeState.h>

Inheritance diagram for juce::AudioProcessorValueTreeState::Parameter:
juce::AudioParameterFloat juce::RangedAudioParameter juce::AudioProcessorParameterWithID juce::HostedAudioProcessorParameter juce::AudioProcessorParameter

Public Member Functions

 Parameter (const ParameterID &parameterID, const String &parameterName, NormalisableRange< float > valueRange, float defaultValue, const AudioProcessorValueTreeStateParameterAttributes &attributes={})
 Parameter (const ParameterID &parameterID, const String &parameterName, const String &labelText, NormalisableRange< float > valueRange, float defaultParameterValue, std::function< String(float)> valueToTextFunction, std::function< float(const String &)> textToValueFunction, bool isMetaParameter=false, bool isAutomatableParameter=true, bool isDiscrete=false, AudioProcessorParameter::Category parameterCategory=AudioProcessorParameter::genericParameter, bool isBoolean=false)
float getDefaultValue () const override
int getNumSteps () const override
bool isDiscrete () const override
bool isBoolean () const override
Public Member Functions inherited from juce::AudioParameterFloat
 AudioParameterFloat (const ParameterID &parameterID, const String &parameterName, NormalisableRange< float > normalisableRange, float defaultValue, const AudioParameterFloatAttributes &attributes={})
 AudioParameterFloat (const ParameterID &parameterID, const String &parameterName, NormalisableRange< float > normalisableRange, float defaultValue, const String &parameterLabel, Category parameterCategory=AudioProcessorParameter::genericParameter, std::function< String(float value, int maximumStringLength)> stringFromValue=nullptr, std::function< float(const String &text)> valueFromString=nullptr)
 AudioParameterFloat (const ParameterID &parameterID, const String &parameterName, float minValue, float maxValue, float defaultValue)
 ~AudioParameterFloat () override
float get () const noexcept
 operator float () const noexcept
AudioParameterFloatoperator= (float newValue)
const NormalisableRange< float > & getNormalisableRange () const override
Public Member Functions inherited from juce::RangedAudioParameter
int getNumSteps () const override
float convertTo0to1 (float v) const noexcept
float convertFrom0to1 (float v) const noexcept
 AudioProcessorParameterWithID (const ParameterID &parameterID, const String &parameterName, const AudioProcessorParameterWithIDAttributes &attributes={})
 AudioProcessorParameterWithID (const ParameterID &parameterID, const String &parameterName, const String &parameterLabel, Category parameterCategory=AudioProcessorParameter::genericParameter)
Public Member Functions inherited from juce::AudioProcessorParameterWithID
 AudioProcessorParameterWithID (const ParameterID &parameterID, const String &parameterName, const AudioProcessorParameterWithIDAttributes &attributes={})
 AudioProcessorParameterWithID (const ParameterID &parameterID, const String &parameterName, const String &parameterLabel, Category parameterCategory=AudioProcessorParameter::genericParameter)
String getName (int) const override
String getLabel () const override
Category getCategory () const override
String getParameterID () const override
bool isMetaParameter () const override
bool isAutomatable () const override
bool isOrientationInverted () const override
Public Member Functions inherited from juce::HostedAudioProcessorParameter
 AudioProcessorParameter () noexcept=default
 AudioProcessorParameter (int versionHint)
Public Member Functions inherited from juce::AudioProcessorParameter
 AudioProcessorParameter () noexcept=default
 AudioProcessorParameter (int versionHint)
virtual ~AudioProcessorParameter ()
void setValueNotifyingHost (float newValue)
void beginChangeGesture ()
void endChangeGesture ()
int getParameterIndex () const noexcept
virtual String getCurrentValueAsText () const
virtual StringArray getAllValueStrings () const
int getVersionHint () const
void addListener (Listener *newListener)
void removeListener (Listener *listener)
void sendValueChangedMessageToListeners (float newValue)

Private Member Functions

void valueChanged (float) override

Private Attributes

std::function< void()> onValueChanged
const float unsnappedDefault
const bool discrete
const bool boolean
std::atomic< float > lastValue { -1.0f }

Friends

class AudioProcessorValueTreeState::ParameterAdapter

Additional Inherited Members

Public Types inherited from juce::AudioProcessorParameter
enum  Category {
  genericParameter = (0 << 16) | 0 , inputGain = (1 << 16) | 0 , outputGain = (1 << 16) | 1 , inputMeter = (2 << 16) | 0 ,
  outputMeter = (2 << 16) | 1 , compressorLimiterGainReductionMeter = (2 << 16) | 2 , expanderGateGainReductionMeter = (2 << 16) | 3 , analysisMeter = (2 << 16) | 4 ,
  otherMeter = (2 << 16) | 5
}
Public Attributes inherited from juce::AudioParameterFloat
NormalisableRange< float > range
Public Attributes inherited from juce::AudioProcessorParameterWithID
const String paramID
const String name
const String label
const Category category

Detailed Description

A parameter class that maintains backwards compatibility with deprecated AudioProcessorValueTreeState functionality.

Previous calls to

createAndAddParameter (paramID1, paramName1, ...);
RangedAudioParameter * createAndAddParameter(const String &parameterID, const String &parameterName, const String &labelText, NormalisableRange< float > valueRange, float defaultValue, std::function< String(float)> valueToTextFunction, std::function< float(const String &)> textToValueFunction, bool isMetaParameter=false, bool isAutomatableParameter=true, bool isDiscrete=false, AudioProcessorParameter::Category parameterCategory=AudioProcessorParameter::genericParameter, bool isBoolean=false)
Definition juce_AudioProcessorValueTreeState.cpp:279

can be replaced with

createAndAddParameter (std::make_unique<Parameter> (paramID1, paramName1, ...));
Definition juce_AudioProcessorValueTreeState.h:453
Parameter(const ParameterID &parameterID, const String &parameterName, NormalisableRange< float > valueRange, float defaultValue, const AudioProcessorValueTreeStateParameterAttributes &attributes={})
Definition juce_AudioProcessorValueTreeState.cpp:31

However, a much better approach is to use the AudioProcessorValueTreeState constructor directly

YourAudioProcessor()
: apvts (*this, &undoManager, "PARAMETERS", { std::make_unique<Parameter> (paramID1, paramName1, ...),
std::make_unique<Parameter> (paramID2, paramName2, ...),
... })
UndoManager *const undoManager
Definition juce_AudioProcessorValueTreeState.h:417

Constructor & Destructor Documentation

◆ Parameter() [1/2]

juce::AudioProcessorValueTreeState::Parameter::Parameter ( const ParameterID & parameterID,
const String & parameterName,
NormalisableRange< float > valueRange,
float defaultValue,
const AudioProcessorValueTreeStateParameterAttributes & attributes = {} )

Constructs a parameter instance.

Example usage:

auto parameter = std::make_unique<Parameter> (ParameterID { "uniqueID", 1 },
"Name",
NormalisableRange<float> { 0.0f, 100.0f },
50.0f,
Attributes().withStringFromValueFunction (myStringFromValueFunction)
.withValueFromStringFunction (myValueFromStringFunction)
.withLabel ("%"));
Definition juce_AudioProcessorValueTreeState.h:37
Definition juce_NormalisableRange.h:40
Definition juce_AudioProcessorParameterWithID.h:33
Parameters
parameterIDThe globally-unique identifier of this parameter
parameterNameThe user-facing name of this parameter
valueRangeThe valid range of values for this parameter
defaultValueThe initial parameter value
AttributesFurther advanced settings to customise the behaviour of this parameter

◆ Parameter() [2/2]

juce::AudioProcessorValueTreeState::Parameter::Parameter ( const ParameterID & parameterID,
const String & parameterName,
const String & labelText,
NormalisableRange< float > valueRange,
float defaultParameterValue,
std::function< String(float)> valueToTextFunction,
std::function< float(const String &)> textToValueFunction,
bool isMetaParameter = false,
bool isAutomatableParameter = true,
bool isDiscrete = false,
AudioProcessorParameter::Category parameterCategory = AudioProcessorParameter::genericParameter,
bool isBoolean = false )
inline

Member Function Documentation

◆ getDefaultValue()

float juce::AudioProcessorValueTreeState::Parameter::getDefaultValue ( ) const
overridevirtual

This should return the default value for this parameter.

Reimplemented from juce::AudioParameterFloat.

◆ getNumSteps()

int juce::AudioProcessorValueTreeState::Parameter::getNumSteps ( ) const
overridevirtual

Returns the number of steps that this parameter's range should be quantised into.

If you want a continuous range of values, don't override this method, and allow the default implementation to return AudioProcessor::getDefaultNumParameterSteps().

If your parameter is boolean, then you may want to make this return 2.

The value that is returned may or may not be used, depending on the host. If you want the host to display stepped automation values, rather than a continuous interpolation between successive values, you should override isDiscrete to return true.

See also
isDiscrete

Reimplemented from juce::AudioParameterFloat.

◆ isBoolean()

bool juce::AudioProcessorValueTreeState::Parameter::isBoolean ( ) const
overridevirtual

Returns whether the parameter represents a boolean switch, typically with "On" and "Off" states.

This information may or may not be used, depending on the host. If you want the host to display a switch, rather than a two item dropdown menu, override this method to return true. You also need to override isDiscrete() to return true and getNumSteps() to return 2.

See also
isDiscrete getNumSteps

Reimplemented from juce::AudioProcessorParameter.

◆ isDiscrete()

bool juce::AudioProcessorValueTreeState::Parameter::isDiscrete ( ) const
overridevirtual

Returns whether the parameter uses discrete values, based on the result of getNumSteps, or allows the host to select values continuously.

This information may or may not be used, depending on the host. If you want the host to display stepped automation values, rather than a continuous interpolation between successive values, override this method to return true.

See also
getNumSteps

Reimplemented from juce::AudioProcessorParameter.

◆ valueChanged()

void juce::AudioProcessorValueTreeState::Parameter::valueChanged ( float newValue)
overrideprivatevirtual

Override this method if you are interested in receiving callbacks when the parameter value changes.

Reimplemented from juce::AudioParameterFloat.

◆ AudioProcessorValueTreeState::ParameterAdapter

Member Data Documentation

◆ boolean

const bool juce::AudioProcessorValueTreeState::Parameter::boolean
private

◆ discrete

const bool juce::AudioProcessorValueTreeState::Parameter::discrete
private

◆ lastValue

std::atomic<float> juce::AudioProcessorValueTreeState::Parameter::lastValue { -1.0f }
private

◆ onValueChanged

std::function<void()> juce::AudioProcessorValueTreeState::Parameter::onValueChanged
private

◆ unsnappedDefault

const float juce::AudioProcessorValueTreeState::Parameter::unsnappedDefault
private

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