From e49022bfba18ae484f892f21bae056c51fed48fa Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 17 Nov 2016 14:18:00 +0000 Subject: [PATCH] Added JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS option to workaround a Studio One bug --- .../juce_audio_plugin_client/AU/juce_AU_Wrapper.mm | 10 +++++++++- .../VST3/juce_VST3_Wrapper.cpp | 7 +++++++ .../juce_audio_plugin_client.h | 13 +++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index 2180ab1741..b91bb2a738 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -1698,7 +1698,15 @@ private: if (isPositiveAndBelow (paramIndex, n)) { const String& juceParamID = juceFilter->getParameterID (paramIndex); - return usingManagedParameter ? static_cast (juceParamID.hashCode()) + + AudioUnitParameterID paramHash = static_cast (juceParamID.hashCode()); + + #if JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS + // studio one doesn't like negative parameters + paramHash &= ~(1 << (sizeof (AudioUnitParameterID) * 8 - 1)); + #endif + + return usingManagedParameter ? paramHash : static_cast (juceParamID.getIntValue()); } 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 d170257df5..9037cea7f7 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -683,6 +683,13 @@ private: if (isPositiveAndBelow (paramIndex, n)) { const String& juceParamID = pluginFilter->getParameterID (paramIndex); + + Vst::ParamID paramHash = static_cast (juceParamID.hashCode()); + #if JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS + // studio one doesn't like negative parameters + paramHash &= ~(1 << (sizeof (Vst::ParamID) * 8 - 1)); + #endif + return managedParameter ? static_cast (juceParamID.hashCode()) : static_cast (juceParamID.getIntValue()); } diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client.h b/modules/juce_audio_plugin_client/juce_audio_plugin_client.h index 4b015e6ab9..5d7e13e1b0 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client.h +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client.h @@ -64,6 +64,19 @@ #define JUCE_FORCE_USE_LEGACY_PARAM_IDS 0 #endif +/** Config: JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS + + Enable this if you want JUCE to use parameter ids which are compatible + to Studio One. Studio One ignores any parameter ids which are negative. + Enabling this option will make JUCE generate only positive parameter ids. + Note that if you have already released a plug-in prio to JUCE 4.3.0 then + enabling this will change your parameter ids making your plug-in + incompatible to old automation data. + */ +#ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS + #define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 +#endif + namespace juce { #include "utility/juce_PluginHostType.h"