From 210ed82ca26b047b2e00f0d8f913996a2dc9228c Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 5 Jan 2023 15:39:28 +0000 Subject: [PATCH] VST3 Host: Send parameter changes to IEditController, even when process is not being called Previously, all parameter changes were routed first into cachedParamValues. Then, on each audio callback, an update would be sent to the editor via the parameterDispatcher for each changed value in cachedParamValues. Now, parameter changes are immediately added to the parameterDispatcher, without needing to wait for an audio callback. --- .../juce_audio_processors/format_types/juce_VST3Common.h | 4 ++-- .../format_types/juce_VST3PluginFormat.cpp | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VST3Common.h b/modules/juce_audio_processors/format_types/juce_VST3Common.h index 5d651d0614..cf7f2a8143 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3Common.h +++ b/modules/juce_audio_processors/format_types/juce_VST3Common.h @@ -1261,7 +1261,7 @@ private: const auto controlEvent = toVst3ControlEvent (msg); - if (! controlEvent.hasValue()) + if (! controlEvent.has_value()) return false; const auto controlParamID = midiMapping->getMapping (createSafeChannel (msg.getChannel()), @@ -1561,7 +1561,7 @@ private: Steinberg::Vst::ParamValue paramValue; }; - static Optional toVst3ControlEvent (const MidiMessage& msg) + static std::optional toVst3ControlEvent (const MidiMessage& msg) { if (msg.isController()) return Vst3MidiControlEvent { (Steinberg::Vst::CtrlNumber) msg.getControllerNumber(), msg.getControllerValue() / 127.0 }; diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 7dca5a5b54..7865d50bda 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -2211,6 +2211,7 @@ public: void setValue (float newValue) override { pluginInstance.cachedParamValues.set (vstParamIndex, newValue); + pluginInstance.parameterDispatcher.push (vstParamIndex, newValue); } /* If we're syncing the editor to the processor, the processor won't need to @@ -2680,11 +2681,6 @@ public: inputParameterChanges->set (cachedParamValues.getParamID (index), value); }); - inputParameterChanges->forEach ([&] (Steinberg::int32 index, float value) - { - parameterDispatcher.push (index, value); - }); - processor->process (data); outputParameterChanges->forEach ([&] (Steinberg::int32 index, float value)