From 3186522b0bd8801b6fe50f917e96dca3f9d500bf Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 25 Nov 2024 16:45:01 +0000 Subject: [PATCH] VST3 Host: Fix bug where MIDI CCs mapped to parameters would fail to update the host and editcontroller --- .../format_types/juce_VST3Common.h | 2 +- .../format_types/juce_VST3PluginFormat.cpp | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VST3Common.h b/modules/juce_audio_processors/format_types/juce_VST3Common.h index 8b1171ebbb..6b93925de9 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3Common.h +++ b/modules/juce_audio_processors/format_types/juce_VST3Common.h @@ -1430,7 +1430,7 @@ private: controlEvent->controllerNumber); if (controlParamID != Steinberg::Vst::kNoParamId) - callback (controlParamID, controlEvent->paramValue, msg.getTimeStamp()); + callback (controlParamID, (float) controlEvent->paramValue, msg.getTimeStamp()); return true; } diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 41cddcc03c..fb122ff5d0 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -2593,6 +2593,11 @@ public: return cachedInfo; } + Steinberg::int32 getVstParamIndex() const + { + return vstParamIndex; + } + private: Vst::ParameterInfo fetchParameterInfo() const { @@ -3770,12 +3775,21 @@ private: if (acceptsMidi()) { - const auto midiMessageCallback = [&] (auto controlID, auto paramValue, auto time) + const auto midiMessageCallback = [&] (auto controlID, float paramValue, auto time) { Steinberg::int32 queueIndex{}; if (auto* queue = inputParameterChanges->addParameterData (controlID, queueIndex)) - queue->append ({ (Steinberg::int32) time, (float) paramValue }); + queue->append ({ (Steinberg::int32) time, paramValue }); + + if (auto* param = getParameterForID (controlID)) + { + // Send the parameter value to the editor + parameterDispatcher.push (param->getVstParamIndex(), paramValue); + + // Update the host's view of the parameter value + param->setValueWithoutUpdatingProcessor (paramValue); + } }; MidiEventList::hostToPluginEventList (*midiInputs,