mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-06 04:00:08 +00:00
Fixed some issues with plug-in parameter IDs
This commit is contained in:
parent
208c7923dc
commit
20ced1662e
3 changed files with 56 additions and 44 deletions
|
|
@ -1840,28 +1840,27 @@ private:
|
|||
void addParameters()
|
||||
{
|
||||
juceParameters.update (*juceFilter, forceUseLegacyParamIDs);
|
||||
|
||||
// check if all parameters are managed?
|
||||
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)));
|
||||
|
||||
auParamIDs.add (auParamID);
|
||||
paramMap.set (static_cast<int32> (auParamID), param);
|
||||
|
||||
if (juceParameters.isUsingManagedParameters())
|
||||
Globals()->SetParameter (auParamID, param->getValue());
|
||||
}
|
||||
|
||||
if (! juceParameters.isUsingManagedParameters())
|
||||
Globals()->UseIndexedParameters (numParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto* param : juceParameters.params)
|
||||
{
|
||||
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)));
|
||||
|
||||
auParamIDs.add (auParamID);
|
||||
paramMap.set (static_cast<int32> (auParamID), param);
|
||||
Globals()->SetParameter (auParamID, param->getValue());
|
||||
}
|
||||
}
|
||||
|
||||
#if JUCE_DEBUG
|
||||
// Some hosts can't handle the huge numbers of discrete parameter values created when
|
||||
|
|
@ -1917,14 +1916,14 @@ private:
|
|||
paramHash &= ~(1 << (sizeof (AudioUnitParameterID) * 8 - 1));
|
||||
#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
|
||||
{
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
// Consider yourself very unlucky if you hit this assertion. The hash codes of your
|
||||
|
|
@ -1570,30 +1569,37 @@ private:
|
|||
}
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
|
|
|
|||
|
|
@ -104,15 +104,14 @@ public:
|
|||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
|
|
@ -205,6 +204,10 @@ private:
|
|||
Vst::ParamID generateVSTParamIDForParam (AudioProcessorParameter* param)
|
||||
{
|
||||
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());
|
||||
|
||||
#if JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS
|
||||
|
|
@ -212,8 +215,8 @@ private:
|
|||
paramHash &= ~(1 << (sizeof (Vst::ParamID) * 8 - 1));
|
||||
#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
|
||||
{
|
||||
toString128 (result, param.getText ((float) value, 128));
|
||||
if (LegacyAudioParameter::isLegacy (¶m))
|
||||
// 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
|
||||
|
|
@ -718,7 +725,7 @@ private:
|
|||
|
||||
if (parameters.getParameterCount() <= 0)
|
||||
{
|
||||
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
|
||||
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
|
||||
const bool forceLegacyParamIDs = true;
|
||||
#else
|
||||
const bool forceLegacyParamIDs = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue