Skip to content

Commit

Permalink
VST3: Added explicit check for current program value in setComponentS…
Browse files Browse the repository at this point in the history
…tate() so it is recalled correctly when loading
  • Loading branch information
ed95 committed Jan 26, 2021
1 parent 99112cf commit cc9fdc3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,22 @@ class JuceVST3EditController : public Vst::EditController,
//==============================================================================
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);
Expand Down

0 comments on commit cc9fdc3

Please sign in to comment.