From 1610d793147cbf9775fa533a62143cd3d0fbfe10 Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Thu, 2 Jan 2020 17:04:19 +0000 Subject: [PATCH] VST3: Fixed a hosting parameter order bug --- .../format_types/juce_VST3PluginFormat.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index ff99a5485a..4e290c5348 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -1594,9 +1594,11 @@ public: struct VST3Parameter final : public Parameter { VST3Parameter (VST3PluginInstance& parent, + int vstParameterIndex, Steinberg::Vst::ParamID parameterID, bool parameterIsAutomatable) : pluginInstance (parent), + vstParamIndex (vstParameterIndex), paramID (parameterID), automatable (parameterIsAutomatable) { @@ -1654,19 +1656,24 @@ public: return Parameter::getValueForText (text); } + Vst::ParameterInfo getParameterInfo() const + { + return pluginInstance.getParameterInfoForIndex (vstParamIndex); + } + float getDefaultValue() const override { - return (float) pluginInstance.getParameterInfoForIndex (getParameterIndex()).defaultNormalizedValue; + return (float) getParameterInfo().defaultNormalizedValue; } String getName (int /*maximumStringLength*/) const override { - return toString (pluginInstance.getParameterInfoForIndex (getParameterIndex()).title); + return toString (getParameterInfo().title); } String getLabel() const override { - return toString (pluginInstance.getParameterInfoForIndex (getParameterIndex()).units); + return toString (getParameterInfo().units); } bool isAutomatable() const override @@ -1681,7 +1688,7 @@ public: int getNumSteps() const override { - auto stepCount = pluginInstance.getParameterInfoForIndex (getParameterIndex()).stepCount; + auto stepCount = getParameterInfo().stepCount; return stepCount == 0 ? AudioProcessor::getDefaultNumParameterSteps() : stepCount + 1; } @@ -1692,6 +1699,7 @@ public: } VST3PluginInstance& pluginInstance; + const int vstParamIndex; const Steinberg::Vst::ParamID paramID; const bool automatable; }; @@ -1700,7 +1708,7 @@ public: VST3PluginInstance (VST3ComponentHolder* componentHolder) : AudioPluginInstance (getBusProperties (componentHolder->component)), holder (componentHolder), - inputParameterChanges (new ParamValueQueueList()), + inputParameterChanges (new ParamValueQueueList()), outputParameterChanges (new ParamValueQueueList()), midiInputs (new MidiEventList()), midiOutputs (new MidiEventList()) @@ -2571,6 +2579,7 @@ private: { auto paramInfo = getParameterInfoForIndex (i); auto* param = new VST3Parameter (*this, + i, paramInfo.id, (paramInfo.flags & Vst::ParameterInfo::kCanAutomate) != 0); @@ -2578,7 +2587,6 @@ private: bypassParam = param; std::function findOrCreateGroup; - findOrCreateGroup = [&groupMap, &infoMap, &findOrCreateGroup](Vst::UnitID groupID) { auto existingGroup = groupMap.find (groupID);