Browse Source

Fixed some issues with plug-in parameter IDs

tags/2021-05-28
Tom Poole 7 years ago
parent
commit
20ced1662e
3 changed files with 54 additions and 42 deletions
  1. +18
    -19
      modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm
  2. +19
    -13
      modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm
  3. +17
    -10
      modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp

+ 18
- 19
modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm View File

@@ -1840,29 +1840,28 @@ private:
void addParameters() void addParameters()
{ {
juceParameters.update (*juceFilter, forceUseLegacyParamIDs); juceParameters.update (*juceFilter, forceUseLegacyParamIDs);
// check if all parameters are managed?
const int numParams = juceParameters.getNumParameters(); const int numParams = juceParameters.getNumParameters();
for (auto* param : juceParameters.params)
if (forceUseLegacyParamIDs)
{ {
const AudioUnitParameterID auParamID = generateAUParameterID (param);
// Consider yourself very unlucky if you hit this assertion. The hash code of your
// parameter ids are not unique.
jassert (! paramMap.contains (static_cast<int32> (auParamID)));
Globals()->UseIndexedParameters (numParams);
}
else
{
for (auto* param : juceParameters.params)
{
const AudioUnitParameterID auParamID = generateAUParameterID (param);
auParamIDs.add (auParamID);
paramMap.set (static_cast<int32> (auParamID), param);
// Consider yourself very unlucky if you hit this assertion. The hash code of your
// parameter ids are not unique.
jassert (! paramMap.contains (static_cast<int32> (auParamID)));
if (juceParameters.isUsingManagedParameters())
auParamIDs.add (auParamID);
paramMap.set (static_cast<int32> (auParamID), param);
Globals()->SetParameter (auParamID, param->getValue()); Globals()->SetParameter (auParamID, param->getValue());
}
} }
if (! juceParameters.isUsingManagedParameters())
Globals()->UseIndexedParameters (numParams);
#if JUCE_DEBUG #if JUCE_DEBUG
// Some hosts can't handle the huge numbers of discrete parameter values created when // Some hosts can't handle the huge numbers of discrete parameter values created when
// using the default number of steps. // using the default number of steps.
@@ -1917,14 +1916,14 @@ private:
paramHash &= ~(1 << (sizeof (AudioUnitParameterID) * 8 - 1)); paramHash &= ~(1 << (sizeof (AudioUnitParameterID) * 8 - 1));
#endif #endif
return juceParameters.isUsingManagedParameters() ? paramHash
: static_cast<AudioUnitParameterID> (juceParamID.getIntValue());
return forceUseLegacyParamIDs ? static_cast<AudioUnitParameterID> (juceParamID.getIntValue())
: paramHash;
} }
inline AudioUnitParameterID getAUParameterIDForIndex (int paramIndex) const noexcept inline AudioUnitParameterID getAUParameterIDForIndex (int paramIndex) const noexcept
{ {
return juceParameters.isUsingManagedParameters() ? auParamIDs.getReference (paramIndex)
: static_cast<AudioUnitParameterID> (paramIndex);
return forceUseLegacyParamIDs ? static_cast<AudioUnitParameterID> (paramIndex)
: auParamIDs.getReference (paramIndex);
} }
AudioProcessorParameter* getParameterForAUParameterID (AudioUnitParameterID address) const noexcept AudioProcessorParameter* getParameterForAUParameterID (AudioUnitParameterID address) const noexcept


+ 19
- 13
modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm View File

@@ -1238,8 +1238,7 @@ private:
} }
} }
AUParameterAddress address = forceLegacyParamIDs ? static_cast<AUParameterAddress> (idx)
: generateAUParameterAddress (juceParam);
AUParameterAddress address = generateAUParameterAddress (juceParam);
#if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE
// Consider yourself very unlucky if you hit this assertion. The hash codes of your // Consider yourself very unlucky if you hit this assertion. The hash codes of your
@@ -1570,30 +1569,37 @@ private:
} }
void parameterGestureChanged (int, bool) override {} void parameterGestureChanged (int, bool) override {}
//============================================================================== //==============================================================================
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
inline AUParameterAddress getAUParameterAddressForIndex (int paramIndex) const noexcept { return static_cast<AUParameterAddress> (paramIndex); }
inline int getJuceParameterIndexForAUAddress (AUParameterAddress address) const noexcept { return static_cast<int> (address); }
#else
inline AUParameterAddress getAUParameterAddressForIndex (int paramIndex) const noexcept inline AUParameterAddress getAUParameterAddressForIndex (int paramIndex) const noexcept
{ {
return juceParameters.isUsingManagedParameters() ? paramAddresses.getReference (paramIndex)
: static_cast<AUParameterAddress> (paramIndex);
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
return static_cast<AUParameterAddress> (paramIndex);
#else
return paramAddresses.getReference (paramIndex);
#endif
} }
inline int getJuceParameterIndexForAUAddress (AUParameterAddress address) const noexcept inline int getJuceParameterIndexForAUAddress (AUParameterAddress address) const noexcept
{ {
return juceParameters.isUsingManagedParameters() ? paramMap[static_cast<int64> (address)]
: static_cast<int> (address);
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
return static_cast<int> (address);
#else
return paramMap[static_cast<int64> (address)];
#endif
} }
#endif
AUParameterAddress generateAUParameterAddress (AudioProcessorParameter* param) const AUParameterAddress generateAUParameterAddress (AudioProcessorParameter* param) const
{ {
const String& juceParamID = LegacyAudioParameter::getParamID (param, forceLegacyParamIDs); const String& juceParamID = LegacyAudioParameter::getParamID (param, forceLegacyParamIDs);
return juceParameters.isUsingManagedParameters() ? static_cast<AUParameterAddress> (juceParamID.hashCode64())
: static_cast<AUParameterAddress> (juceParamID.getIntValue());
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
auto result = juceParamID.getIntValue();
#else
auto result = juceParamID.hashCode64();
#endif
return static_cast<AUParameterAddress> (result);
} }
AudioProcessorParameter* getJuceParameterForAUAddress (AUParameterAddress address) const noexcept AudioProcessorParameter* getJuceParameterForAUAddress (AUParameterAddress address) const noexcept


+ 17
- 10
modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp View File

@@ -104,15 +104,14 @@ public:
JUCE_DECLARE_VST3_COM_REF_METHODS JUCE_DECLARE_VST3_COM_REF_METHODS
//============================================================================== //==============================================================================
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
inline Vst::ParamID getVSTParamIDForIndex (int paramIndex) const noexcept { return static_cast<Vst::ParamID> (paramIndex); }
#else
inline Vst::ParamID getVSTParamIDForIndex (int paramIndex) const noexcept inline Vst::ParamID getVSTParamIDForIndex (int paramIndex) const noexcept
{ {
return isUsingManagedParameters() ? vstParamIDs.getReference (paramIndex)
: static_cast<Vst::ParamID> (paramIndex);
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
return static_cast<Vst::ParamID> (paramIndex);
#else
return vstParamIDs.getReference (paramIndex);
#endif
} }
#endif
AudioProcessorParameter* getParamForVSTParamID (Vst::ParamID paramID) const noexcept AudioProcessorParameter* getParamForVSTParamID (Vst::ParamID paramID) const noexcept
{ {
@@ -205,6 +204,10 @@ private:
Vst::ParamID generateVSTParamIDForParam (AudioProcessorParameter* param) Vst::ParamID generateVSTParamIDForParam (AudioProcessorParameter* param)
{ {
auto juceParamID = LegacyAudioParameter::getParamID (param, false); auto juceParamID = LegacyAudioParameter::getParamID (param, false);
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
return static_cast<Vst::ParamID> (juceParamID.getIntValue());
#else
auto paramHash = static_cast<Vst::ParamID> (juceParamID.hashCode()); auto paramHash = static_cast<Vst::ParamID> (juceParamID.hashCode());
#if JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS #if JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS
@@ -212,8 +215,8 @@ private:
paramHash &= ~(1 << (sizeof (Vst::ParamID) * 8 - 1)); paramHash &= ~(1 << (sizeof (Vst::ParamID) * 8 - 1));
#endif #endif
return isUsingManagedParameters() ? paramHash
: static_cast<Vst::ParamID> (juceParamID.getIntValue());
return paramHash;
#endif
} }
//============================================================================== //==============================================================================
@@ -389,7 +392,11 @@ public:
void toString (Vst::ParamValue value, Vst::String128 result) const override void toString (Vst::ParamValue value, Vst::String128 result) const override
{ {
toString128 (result, param.getText ((float) value, 128));
if (LegacyAudioParameter::isLegacy (&param))
// remain backward-compatible with old JUCE code
toString128 (result, param.getCurrentValueAsText());
else
toString128 (result, param.getText ((float) value, 128));
} }
bool fromString (const Vst::TChar* text, Vst::ParamValue& outValueNormalized) const override bool fromString (const Vst::TChar* text, Vst::ParamValue& outValueNormalized) const override
@@ -718,7 +725,7 @@ private:
if (parameters.getParameterCount() <= 0) if (parameters.getParameterCount() <= 0)
{ {
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
const bool forceLegacyParamIDs = true; const bool forceLegacyParamIDs = true;
#else #else
const bool forceLegacyParamIDs = false; const bool forceLegacyParamIDs = false;


Loading…
Cancel
Save