Browse Source

Fixed a parameter change recursion issue in the VST and AU wrappers

tags/2021-05-28
Tom Poole 7 years ago
parent
commit
dd684b1a5d
2 changed files with 26 additions and 0 deletions
  1. +12
    -0
      modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm
  2. +14
    -0
      modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp

+ 12
- 0
modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm View File

@@ -131,6 +131,8 @@ public:
isBypassed (false), isBypassed (false),
mapper (*juceFilter) mapper (*juceFilter)
{ {
inParameterChangedCallback = false;
#ifdef JucePlugin_PreferredChannelConfigurations #ifdef JucePlugin_PreferredChannelConfigurations
short configs[][2] = {JucePlugin_PreferredChannelConfigurations}; short configs[][2] = {JucePlugin_PreferredChannelConfigurations};
const int numConfigs = sizeof (configs) / sizeof (short[2]); const int numConfigs = sizeof (configs) / sizeof (short[2]);
@@ -963,6 +965,8 @@ public:
if (auto* param = juceFilter->getParameters()[index]) if (auto* param = juceFilter->getParameters()[index])
{ {
param->setValue (value); param->setValue (value);
inParameterChangedCallback = true;
param->sendValueChangedMessageToListeners (value); param->sendValueChangedMessageToListeners (value);
} }
else else
@@ -1085,6 +1089,12 @@ public:
void audioProcessorParameterChanged (AudioProcessor*, int index, float /*newValue*/) override void audioProcessorParameterChanged (AudioProcessor*, int index, float /*newValue*/) override
{ {
if (inParameterChangedCallback.get())
{
inParameterChangedCallback = false;
return;
}
sendAUEvent (kAudioUnitEvent_ParameterValueChange, index); sendAUEvent (kAudioUnitEvent_ParameterValueChange, index);
} }
@@ -1665,6 +1675,8 @@ private:
int totalInChannels, totalOutChannels; int totalInChannels, totalOutChannels;
HeapBlock<bool> pulledSucceeded; HeapBlock<bool> pulledSucceeded;
ThreadLocalValue<bool> inParameterChangedCallback;
//============================================================================== //==============================================================================
Array<AUChannelInfo> channelInfo; Array<AUChannelInfo> channelInfo;
Array<Array<AudioChannelLayoutTag>> supportedInputLayouts, supportedOutputLayouts; Array<Array<AudioChannelLayoutTag>> supportedInputLayouts, supportedOutputLayouts;


+ 14
- 0
modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp View File

@@ -260,6 +260,8 @@ public:
: hostCallback (cb), : hostCallback (cb),
processor (af) processor (af)
{ {
inParameterChangedCallback = false;
// VST-2 does not support disabling buses: so always enable all of them // VST-2 does not support disabling buses: so always enable all of them
processor->enableAllBuses(); processor->enableAllBuses();
@@ -723,6 +725,8 @@ public:
if (auto* param = processor->getParameters()[index]) if (auto* param = processor->getParameters()[index])
{ {
param->setValue (value); param->setValue (value);
inParameterChangedCallback = true;
param->sendValueChangedMessageToListeners (value); param->sendValueChangedMessageToListeners (value);
} }
else else
@@ -740,6 +744,12 @@ public:
void audioProcessorParameterChanged (AudioProcessor*, int index, float newValue) override void audioProcessorParameterChanged (AudioProcessor*, int index, float newValue) override
{ {
if (inParameterChangedCallback.get())
{
inParameterChangedCallback = false;
return;
}
if (hostCallback != nullptr) if (hostCallback != nullptr)
hostCallback (&vstEffect, hostOpcodeParameterChanged, index, 0, 0, newValue); hostCallback (&vstEffect, hostOpcodeParameterChanged, index, 0, 0, newValue);
} }
@@ -1477,6 +1487,8 @@ private:
HeapBlock<VstSpeakerConfiguration> cachedInArrangement, cachedOutArrangement; HeapBlock<VstSpeakerConfiguration> cachedInArrangement, cachedOutArrangement;
ThreadLocalValue<bool> inParameterChangedCallback;
static JuceVSTWrapper* getWrapper (VstEffectInterface* v) noexcept { return static_cast<JuceVSTWrapper*> (v->effectPointer); } static JuceVSTWrapper* getWrapper (VstEffectInterface* v) noexcept { return static_cast<JuceVSTWrapper*> (v->effectPointer); }
bool isProcessLevelOffline() bool isProcessLevelOffline()
@@ -1828,6 +1840,8 @@ private:
{ {
auto value = param->getValueForText (String::fromUTF8 ((char*) args.ptr)); auto value = param->getValueForText (String::fromUTF8 ((char*) args.ptr));
param->setValue (value); param->setValue (value);
inParameterChangedCallback = true;
param->sendValueChangedMessageToListeners (value); param->sendValueChangedMessageToListeners (value);
return 1; return 1;


Loading…
Cancel
Save