Browse Source

Added an isBoolean flag to APVTS parameters

tags/2021-05-28
Tom Poole 7 years ago
parent
commit
76ed748c79
2 changed files with 14 additions and 6 deletions
  1. +9
    -5
      modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp
  2. +5
    -1
      modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h

+ 9
- 5
modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp View File

@@ -38,14 +38,16 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete
bool meta, bool meta,
bool automatable, bool automatable,
bool discrete, bool discrete,
AudioProcessorParameter::Category category)
AudioProcessorParameter::Category category,
bool boolean)
: AudioProcessorParameterWithID (parameterID, paramName, labelText, category), : AudioProcessorParameterWithID (parameterID, paramName, labelText, category),
owner (s), valueToTextFunction (valueToText), textToValueFunction (textToValue), owner (s), valueToTextFunction (valueToText), textToValueFunction (textToValue),
range (r), value (defaultVal), defaultValue (defaultVal), range (r), value (defaultVal), defaultValue (defaultVal),
listenersNeedCalling (true), listenersNeedCalling (true),
isMetaParam (meta), isMetaParam (meta),
isAutomatableParam (automatable), isAutomatableParam (automatable),
isDiscreteParam (discrete)
isDiscreteParam (discrete),
isBooleanParam (boolean)
{ {
state.addListener (this); state.addListener (this);
needsUpdate.set (1); needsUpdate.set (1);
@@ -152,6 +154,7 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete
bool isMetaParameter() const override { return isMetaParam; } bool isMetaParameter() const override { return isMetaParam; }
bool isAutomatable() const override { return isAutomatableParam; } bool isAutomatable() const override { return isAutomatableParam; }
bool isDiscrete() const override { return isDiscreteParam; } bool isDiscrete() const override { return isDiscreteParam; }
bool isBoolean() const override { return isBooleanParam; }
AudioProcessorValueTreeState& owner; AudioProcessorValueTreeState& owner;
ValueTree state; ValueTree state;
@@ -162,7 +165,7 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete
float value, defaultValue; float value, defaultValue;
Atomic<int> needsUpdate; Atomic<int> needsUpdate;
bool listenersNeedCalling; bool listenersNeedCalling;
const bool isMetaParam, isAutomatableParam, isDiscreteParam;
const bool isMetaParam, isAutomatableParam, isDiscreteParam, isBooleanParam;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Parameter) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Parameter)
}; };
@@ -184,7 +187,8 @@ AudioProcessorParameterWithID* AudioProcessorValueTreeState::createAndAddParamet
bool isMetaParameter, bool isMetaParameter,
bool isAutomatableParameter, bool isAutomatableParameter,
bool isDiscreteParameter, bool isDiscreteParameter,
AudioProcessorParameter::Category category)
AudioProcessorParameter::Category category,
bool isBooleanParameter)
{ {
// All parameters must be created before giving this manager a ValueTree state! // All parameters must be created before giving this manager a ValueTree state!
jassert (! state.isValid()); jassert (! state.isValid());
@@ -192,7 +196,7 @@ AudioProcessorParameterWithID* AudioProcessorValueTreeState::createAndAddParamet
Parameter* p = new Parameter (*this, paramID, paramName, labelText, r, Parameter* p = new Parameter (*this, paramID, paramName, labelText, r,
defaultVal, valueToTextFunction, textToValueFunction, defaultVal, valueToTextFunction, textToValueFunction,
isMetaParameter, isAutomatableParameter, isMetaParameter, isAutomatableParameter,
isDiscreteParameter, category);
isDiscreteParameter, category, isBooleanParameter);
processor.addParameter (p); processor.addParameter (p);
return p; return p;
} }


+ 5
- 1
modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h View File

@@ -84,6 +84,9 @@ public:
@see AudioProcessorParameter::isDiscrete @see AudioProcessorParameter::isDiscrete
@param category Which category the parameter should use. @param category Which category the parameter should use.
@see AudioProcessorParameter::Category @see AudioProcessorParameter::Category
@param isBoolean Set this value to true to make this parameter appear as a boolean toggle in
a hosts view of your plug-ins parameters
@see AudioProcessorParameter::isBoolean
@returns the parameter object that was created @returns the parameter object that was created
*/ */
@@ -98,7 +101,8 @@ public:
bool isAutomatableParameter = true, bool isAutomatableParameter = true,
bool isDiscrete = false, bool isDiscrete = false,
AudioProcessorParameter::Category category AudioProcessorParameter::Category category
= AudioProcessorParameter::genericParameter);
= AudioProcessorParameter::genericParameter,
bool isBoolean = false);
/** Returns a parameter by its ID string. */ /** Returns a parameter by its ID string. */
AudioProcessorParameterWithID* getParameter (StringRef parameterID) const noexcept; AudioProcessorParameterWithID* getParameter (StringRef parameterID) const noexcept;


Loading…
Cancel
Save