Browse Source

APVTS: Fix apvts parameter update recursion

tags/2021-05-28
reuk ed 5 years ago
parent
commit
84849f8808
2 changed files with 15 additions and 4 deletions
  1. +6
    -1
      modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp
  2. +9
    -3
      modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h

+ 6
- 1
modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp View File

@@ -71,7 +71,9 @@ void AudioProcessorValueTreeState::Parameter::valueChanged (float newValue)
return;
lastValue = newValue;
sendValueChangedMessageToListeners (newValue);
if (onValueChanged != nullptr)
onValueChanged();
}
//==============================================================================
@@ -87,6 +89,9 @@ public:
unnormalisedValue (getRange().convertFrom0to1 (parameter.getDefaultValue()))
{
parameter.addListener (this);
if (auto* ptr = dynamic_cast<Parameter*> (&parameter))
ptr->onValueChanged = [this] { parameterValueChanged ({}, {}); };
}
~ParameterAdapter() override { parameter.removeListener (this); }


+ 9
- 3
modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h View File

@@ -362,6 +362,10 @@ public:
UndoManager* const undoManager;
//==============================================================================
private:
class ParameterAdapter;
public:
/** A parameter class that maintains backwards compatibility with deprecated
AudioProcessorValueTreeState functionality.
@@ -416,9 +420,13 @@ public:
private:
void valueChanged (float) override;
std::function<void()> onValueChanged;
const float unsnappedDefault;
const bool metaParameter, automatable, discrete, boolean;
float lastValue = 0.0f;
float lastValue = -1.0f;
friend class AudioProcessorValueTreeState::ParameterAdapter;
};
//==============================================================================
@@ -523,8 +531,6 @@ private:
bool, bool, bool, AudioProcessorParameter::Category, bool));
//==============================================================================
class ParameterAdapter;
#if JUCE_UNIT_TESTS
friend struct ParameterAdapterTests;
#endif


Loading…
Cancel
Save