Browse Source

VST3 Client: Avoid calling performEdit during setState

The host is guaranteed to re-scan all parameter values after setting a
new state on the plugin, so there's no need to notify the host about
parameter changes that happen during the setState call.

This also avoids a problem where Bitwig would complain about invalid
parameter IDs in 'engine.log' when loading projects containing JUCE
VST3s. These log messages were produced because a call to setState was
made before Bitwig registered the plugin's parameters, and the setState
call in turn called performEdit with parameter IDs that were yet to be
registered.
v6.1.6
reuk 3 years ago
parent
commit
89a7d05180
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
1 changed files with 14 additions and 5 deletions
  1. +14
    -5
      modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp

+ 14
- 5
modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp View File

@@ -1174,19 +1174,19 @@ public:
//==============================================================================
void beginGesture (Vst::ParamID vstParamId)
{
if (MessageManager::getInstance()->isThisTheMessageThread())
if (! inSetState && MessageManager::getInstance()->isThisTheMessageThread())
beginEdit (vstParamId);
}
void endGesture (Vst::ParamID vstParamId)
{
if (MessageManager::getInstance()->isThisTheMessageThread())
if (! inSetState && MessageManager::getInstance()->isThisTheMessageThread())
endEdit (vstParamId);
}
void paramChanged (Steinberg::int32 parameterIndex, Vst::ParamID vstParamId, double newValue)
{
if (inParameterChangedCallback)
if (inParameterChangedCallback || inSetState)
return;
if (MessageManager::getInstance()->isThisTheMessageThread())
@@ -1354,6 +1354,7 @@ private:
std::vector<std::unique_ptr<OwnedParameterListener>> ownedParameterListeners;
//==============================================================================
bool inSetState = false;
std::atomic<bool> vst3IsPlaying { false },
inSetupProcessing { false };
@@ -2207,8 +2208,8 @@ class JuceVST3Component : public Vst::IComponent,
{
public:
JuceVST3Component (Vst::IHostApplication* h)
: pluginInstance (createPluginFilterOfType (AudioProcessor::wrapperType_VST3)),
host (h)
: pluginInstance (createPluginFilterOfType (AudioProcessor::wrapperType_VST3)),
host (h)
{
inParameterChangedCallback = false;
@@ -2433,6 +2434,10 @@ public:
void setStateInformation (const void* data, int sizeAsInt)
{
bool unusedState = false;
auto& flagToSet = juceVST3EditController != nullptr ? juceVST3EditController->inSetState : unusedState;
const ScopedValueSetter<bool> scope (flagToSet, true);
auto size = (uint64) sizeAsInt;
// Check if this data was written with a newer JUCE version
@@ -2636,6 +2641,10 @@ public:
tresult PLUGIN_API setState (IBStream* state) override
{
// The VST3 spec requires that this function is called from the UI thread.
// If this assertion fires, your host is misbehaving!
JUCE_ASSERT_MESSAGE_THREAD
if (state == nullptr)
return kInvalidArgument;


Loading…
Cancel
Save