From bd52350c00ee96dc0a3175c7c7191a8fdf3f0c36 Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 12 Jan 2022 19:58:31 +0000 Subject: [PATCH] VST3 Wrapper: Avoid calling processBlock when there is no audio input/output --- .../VST3/juce_VST3_Wrapper.cpp | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index 4455e886e0..ded1cf1a7a 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -3155,9 +3155,27 @@ public: return kResultFalse; } - if (processSetup.symbolicSampleSize == Vst::kSample32) processAudio (data, channelListFloat); - else if (processSetup.symbolicSampleSize == Vst::kSample64) processAudio (data, channelListDouble); - else jassertfalse; + // If all of these are zero, the host is attempting to flush parameters without processing audio. + if (data.numSamples != 0 || data.numInputs != 0 || data.numOutputs != 0) + { + if (processSetup.symbolicSampleSize == Vst::kSample32) processAudio (data, channelListFloat); + else if (processSetup.symbolicSampleSize == Vst::kSample64) processAudio (data, channelListDouble); + else jassertfalse; + } + + if (auto* changes = data.outputParameterChanges) + { + comPluginInstance->forAllChangedParameters ([&] (Vst::ParamID paramID, float value) + { + Steinberg::int32 queueIndex = 0; + + if (auto* queue = changes->addParameterData (paramID, queueIndex)) + { + Steinberg::int32 pointIndex = 0; + queue->addPoint (0, value, pointIndex); + } + }); + } #if JucePlugin_ProducesMidiOutput if (isMidiOutputBusEnabled && data.outputEvents != nullptr) @@ -3381,20 +3399,6 @@ private: jassert (midiBuffer.getNumEvents() <= numMidiEventsComingIn); #endif } - - if (auto* changes = data.outputParameterChanges) - { - comPluginInstance->forAllChangedParameters ([&] (Vst::ParamID paramID, float value) - { - Steinberg::int32 queueIndex = 0; - - if (auto* queue = changes->addParameterData (paramID, queueIndex)) - { - Steinberg::int32 pointIndex = 0; - queue->addPoint (0, value, pointIndex); - } - }); - } } //==============================================================================