Browse Source

Plugin clients: Avoid notifying listeners when parameters have not changed

v6.1.6
reuk 4 years ago
parent
commit
d0615041f0
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
3 changed files with 28 additions and 39 deletions
  1. +5
    -4
      modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm
  2. +11
    -12
      modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp
  3. +12
    -23
      modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp

+ 5
- 4
modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm View File

@@ -1029,10 +1029,11 @@ public:
{ {
auto value = inValue / getMaximumParameterValue (param); auto value = inValue / getMaximumParameterValue (param);
param->setValue (value);
inParameterChangedCallback = true;
param->sendValueChangedMessageToListeners (value);
if (value != param->getValue())
{
inParameterChangedCallback = true;
param->setValueNotifyingHost (value);
}
return noErr; return noErr;
} }


+ 11
- 12
modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp View File

@@ -703,12 +703,7 @@ public:
void setParameter (int32 index, float value) void setParameter (int32 index, float value)
{ {
if (auto* param = juceParameters.getParamForIndex (index)) if (auto* param = juceParameters.getParamForIndex (index))
{
param->setValue (value);
inParameterChangedCallback = true;
param->sendValueChangedMessageToListeners (value);
}
setValueAndNotifyIfChanged (*param, value);
} }
static void setParameterCB (Vst2::AEffect* vstInterface, int32 index, float value) static void setParameterCB (Vst2::AEffect* vstInterface, int32 index, float value)
@@ -1433,6 +1428,15 @@ private:
static void checkWhetherMessageThreadIsCorrect() {} static void checkWhetherMessageThreadIsCorrect() {}
#endif #endif
void setValueAndNotifyIfChanged (AudioProcessorParameter& param, float newValue)
{
if (param.getValue() == newValue)
return;
inParameterChangedCallback = true;
param.setValueNotifyingHost (newValue);
}
//============================================================================== //==============================================================================
template <typename FloatType> template <typename FloatType>
void deleteTempChannels (VstTempBuffers<FloatType>& tmpBuffers) void deleteTempChannels (VstTempBuffers<FloatType>& tmpBuffers)
@@ -1716,12 +1720,7 @@ private:
{ {
if (! LegacyAudioParameter::isLegacy (param)) if (! LegacyAudioParameter::isLegacy (param))
{ {
auto value = param->getValueForText (String::fromUTF8 ((char*) args.ptr));
param->setValue (value);
inParameterChangedCallback = true;
param->sendValueChangedMessageToListeners (value);
setValueAndNotifyIfChanged (*param, param->getValueForText (String::fromUTF8 ((char*) args.ptr)));
return 1; return 1;
} }
} }


+ 12
- 23
modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp View File

@@ -622,6 +622,15 @@ class JuceVST3Component;
static thread_local bool inParameterChangedCallback = false; static thread_local bool inParameterChangedCallback = false;
static void setValueAndNotifyIfChanged (AudioProcessorParameter& param, float newValue)
{
if (param.getValue() == newValue)
return;
const InParameterChangedCallbackSetter scopedSetter { inParameterChangedCallback };
param.setValueNotifyingHost (newValue);
}
//============================================================================== //==============================================================================
class JuceVST3EditController : public Vst::EditController, class JuceVST3EditController : public Vst::EditController,
public Vst::IMidiMapping, public Vst::IMidiMapping,
@@ -745,14 +754,7 @@ public:
// otherwise we get parallel streams of parameter value updates // otherwise we get parallel streams of parameter value updates
// during playback // during playback
if (! owner.vst3IsPlaying) if (! owner.vst3IsPlaying)
{
auto value = static_cast<float> (v);
param.setValue (value);
const InParameterChangedCallbackSetter scopedSetter { inParameterChangedCallback };
param.sendValueChangedMessageToListeners (value);
}
setValueAndNotifyIfChanged (param, (float) v);
changed(); changed();
return true; return true;
@@ -2363,13 +2365,7 @@ public:
void setBypassed (bool shouldBeBypassed) void setBypassed (bool shouldBeBypassed)
{ {
if (auto* bypassParam = comPluginInstance->getBypassParameter()) if (auto* bypassParam = comPluginInstance->getBypassParameter())
{
auto floatValue = (shouldBeBypassed ? 1.0f : 0.0f);
bypassParam->setValue (floatValue);
const InParameterChangedCallbackSetter scopedSetter { inParameterChangedCallback };
bypassParam->sendValueChangedMessageToListeners (floatValue);
}
setValueAndNotifyIfChanged (*bypassParam, shouldBeBypassed ? 1.0f : 0.0f);
} }
//============================================================================== //==============================================================================
@@ -3109,15 +3105,8 @@ public:
else else
#endif #endif
{ {
auto floatValue = static_cast<float> (value);
if (auto* param = comPluginInstance->getParamForVSTParamID (vstParamID)) if (auto* param = comPluginInstance->getParamForVSTParamID (vstParamID))
{
param->setValue (floatValue);
const InParameterChangedCallbackSetter scopedSetter { inParameterChangedCallback };
param->sendValueChangedMessageToListeners (floatValue);
}
setValueAndNotifyIfChanged (*param, (float) value);
} }
} }
} }


Loading…
Cancel
Save