From 9a127e32e48d87b448749f60f26294b746aeed2f Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 25 Jan 2021 09:13:15 +0000 Subject: [PATCH] VST3: Added explicit check for current program value in setComponentState() so it is recalled correctly when loading --- .../VST3/juce_VST3_Wrapper.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 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 21f72ec698..5f326a8009 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -705,9 +705,22 @@ public: //============================================================================== tresult PLUGIN_API setComponentState (IBStream* stream) override { - // Cubase and Nuendo need to inform the host of the current parameter values - for (auto vstParamId : audioProcessor->vstParamIDs) - setParamNormalized (vstParamId, audioProcessor->getParamForVSTParamID (vstParamId)->getValue()); + if (auto* pluginInstance = getPluginInstance()) + { + for (auto vstParamId : audioProcessor->vstParamIDs) + { + auto paramValue = [&] + { + if (vstParamId == JuceAudioProcessor::paramPreset) + return EditController::plainParamToNormalized (JuceAudioProcessor::paramPreset, + pluginInstance->getCurrentProgram()); + + return (double) audioProcessor->getParamForVSTParamID (vstParamId)->getValue(); + }(); + + setParamNormalized (vstParamId, paramValue); + } + } if (auto* handler = getComponentHandler()) handler->restartComponent (Vst::kParamValuesChanged);