From f17425c8807d102c33e4791fe4f523fd97f8e76c Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 9 Sep 2021 16:18:54 +0100 Subject: [PATCH] VST3 Host: Be more forgiving of internal parameter IDs in beginEdit/performEdit/endEdit methods --- .../format_types/juce_VST3PluginFormat.cpp | 48 +++++++++---------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 256d5173b5..d34af91239 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -3437,53 +3437,49 @@ AudioPluginInstance* VST3ComponentHolder::createPluginInstance() //============================================================================== tresult VST3HostContext::beginEdit (Vst::ParamID paramID) { - if (plugin != nullptr) - { - if (auto* param = plugin->getParameterForID (paramID)) - { - param->beginChangeGesture(); - return kResultTrue; - } + if (plugin == nullptr) + return kResultTrue; - jassertfalse; // Invalid parameter index! - return kResultFalse; + if (auto* param = plugin->getParameterForID (paramID)) + { + param->beginChangeGesture(); + return kResultTrue; } - return kResultTrue; + return kResultFalse; } tresult VST3HostContext::performEdit (Vst::ParamID paramID, Vst::ParamValue valueNormalised) { - if (plugin != nullptr) + if (plugin == nullptr) + return kResultTrue; + + if (auto* param = plugin->getParameterForID (paramID)) { - if (auto* param = plugin->getParameterForID (paramID)) - param->setValueFromEditor ((float) valueNormalised); - else - jassertfalse; // Invalid parameter index! + param->setValueFromEditor ((float) valueNormalised); // did the plug-in already update the parameter internally if (plugin->editController->getParamNormalized (paramID) != (float) valueNormalised) return plugin->editController->setParamNormalized (paramID, valueNormalised); + + return kResultTrue; } - return kResultTrue; + return kResultFalse; } tresult VST3HostContext::endEdit (Vst::ParamID paramID) { - if (plugin != nullptr) - { - if (auto* param = plugin->getParameterForID (paramID)) - { - param->endChangeGesture(); - return kResultTrue; - } + if (plugin == nullptr) + return kResultTrue; - jassertfalse; // Invalid parameter index! - return kResultFalse; + if (auto* param = plugin->getParameterForID (paramID)) + { + param->endChangeGesture(); + return kResultTrue; } - return kResultTrue; + return kResultFalse; } tresult VST3HostContext::restartComponent (Steinberg::int32 flags)