Browse Source

Fixed 4dcce50 to support AudioProcessor based parameter selection

tags/2021-05-28
tpoole 8 years ago
parent
commit
f346de10c3
3 changed files with 37 additions and 39 deletions
  1. +8
    -10
      modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp
  2. +21
    -19
      modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm
  3. +8
    -10
      modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp

+ 8
- 10
modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp View File

@@ -1319,14 +1319,12 @@ namespace AAXClasses
for (int parameterIndex = 0; parameterIndex < numParameters; ++parameterIndex) for (int parameterIndex = 0; parameterIndex < numParameters; ++parameterIndex)
{ {
auto* processorParam = audioProcessor.getParameters().getUnchecked (parameterIndex);
const AudioProcessorParameter::Category category = processorParam->getCategory();
const AudioProcessorParameter::Category category = audioProcessor.getParameterCategory (parameterIndex);
aaxParamIDs.add (usingManagedParameters ? audioProcessor.getParameterID (parameterIndex) aaxParamIDs.add (usingManagedParameters ? audioProcessor.getParameterID (parameterIndex)
: String (parameterIndex)); : String (parameterIndex));
AAX_CString paramName (processorParam->getName (31).toRawUTF8());
AAX_CString paramName (audioProcessor.getParameterName (parameterIndex, 31).toRawUTF8());
AAX_CParamID paramID = aaxParamIDs.getReference (parameterIndex).getCharPointer(); AAX_CParamID paramID = aaxParamIDs.getReference (parameterIndex).getCharPointer();
paramMap.set (AAXClasses::getAAXParamHash (paramID), parameterIndex); paramMap.set (AAXClasses::getAAXParamHash (paramID), parameterIndex);
@@ -1341,25 +1339,25 @@ namespace AAXClasses
AAX_IParameter* parameter AAX_IParameter* parameter
= new AAX_CParameter<float> (paramID, = new AAX_CParameter<float> (paramID,
paramName, paramName,
processorParam->getDefaultValue(),
audioProcessor.getParameterDefaultValue (parameterIndex),
AAX_CLinearTaperDelegate<float, 0>(), AAX_CLinearTaperDelegate<float, 0>(),
AAX_CNumberDisplayDelegate<float, 3>(), AAX_CNumberDisplayDelegate<float, 3>(),
audioProcessor.isParameterAutomatable (parameterIndex)); audioProcessor.isParameterAutomatable (parameterIndex));
parameter->AddShortenedName (processorParam->getName (4).toRawUTF8());
parameter->AddShortenedName (audioProcessor.getParameterName (parameterIndex, 4).toRawUTF8());
const int parameterNumSteps = processorParam->getNumSteps();
const int parameterNumSteps = audioProcessor.getParameterNumSteps (parameterIndex);
parameter->SetNumberOfSteps ((uint32_t) parameterNumSteps); parameter->SetNumberOfSteps ((uint32_t) parameterNumSteps);
#if JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE #if JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE
parameter->SetType (parameterNumSteps > 1000 ? AAX_eParameterType_Continuous parameter->SetType (parameterNumSteps > 1000 ? AAX_eParameterType_Continuous
: AAX_eParameterType_Discrete); : AAX_eParameterType_Discrete);
#else #else
parameter->SetType (processorParam->isDiscrete() ? AAX_eParameterType_Discrete
: AAX_eParameterType_Continuous);
parameter->SetType (audioProcessor.isParameterDiscrete (parameterIndex) ? AAX_eParameterType_Discrete
: AAX_eParameterType_Continuous);
#endif #endif
parameter->SetOrientation (processorParam->isOrientationInverted()
parameter->SetOrientation (audioProcessor.isParameterOrientationInverted (parameterIndex)
? (AAX_eParameterOrientation_RightMinLeftMax | AAX_eParameterOrientation_TopMinBottomMax ? (AAX_eParameterOrientation_RightMinLeftMax | AAX_eParameterOrientation_TopMinBottomMax
| AAX_eParameterOrientation_RotarySingleDotMode | AAX_eParameterOrientation_RotaryRightMinLeftMax) | AAX_eParameterOrientation_RotarySingleDotMode | AAX_eParameterOrientation_RotaryRightMinLeftMax)
: (AAX_eParameterOrientation_LeftMinRightMax | AAX_eParameterOrientation_BottomMinTopMax : (AAX_eParameterOrientation_LeftMinRightMax | AAX_eParameterOrientation_BottomMinTopMax


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

@@ -525,7 +525,7 @@ public:
const String text (String::fromCFString (pv->inString)); const String text (String::fromCFString (pv->inString));
if (AudioProcessorParameter* param = juceFilter->getParameters() [paramID]) if (AudioProcessorParameter* param = juceFilter->getParameters() [paramID])
pv->outValue = param->getValueForText (text) * getMaximumParameterValue (param);
pv->outValue = param->getValueForText (text) * getMaximumParameterValue (paramID);
else else
pv->outValue = text.getFloatValue(); pv->outValue = text.getFloatValue();
@@ -546,7 +546,7 @@ public:
String text; String text;
if (AudioProcessorParameter* param = juceFilter->getParameters() [paramID]) if (AudioProcessorParameter* param = juceFilter->getParameters() [paramID])
text = param->getText (value / getMaximumParameterValue (param), 0);
text = param->getText (value / getMaximumParameterValue (paramID), 0);
else else
text = String (value); text = String (value);
@@ -805,13 +805,13 @@ public:
//============================================================================== //==============================================================================
// When parameters are discrete we need to use integer values. // When parameters are discrete we need to use integer values.
static float getMaximumParameterValue (AudioProcessorParameter* param)
float getMaximumParameterValue (int parameterIndex)
{ {
#if JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE #if JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE
ignoreUnused (param);
ignoreUnused (parameterIndex);
return 1.0f; return 1.0f;
#else #else
return param->isDiscrete() ? (float) (param->getNumSteps() - 1) : 1.0f;
return juceFilter->isParameterDiscrete (parameterIndex) ? (float) (juceFilter->getParameterNumSteps (parameterIndex) - 1) : 1.0f;
#endif #endif
} }
@@ -835,22 +835,22 @@ public:
outParameterInfo.flags |= (UInt32) kAudioUnitParameterFlag_IsHighResolution; outParameterInfo.flags |= (UInt32) kAudioUnitParameterFlag_IsHighResolution;
#endif #endif
auto* param = juceFilter->getParameters().getUnchecked (index);
const String name (param->getName (512));
const String name (juceFilter->getParameterName (index));
// Set whether the param is automatable (unnamed parameters aren't allowed to be automated) // Set whether the param is automatable (unnamed parameters aren't allowed to be automated)
if (name.isEmpty() || ! param->isAutomatable())
if (name.isEmpty() || ! juceFilter->isParameterAutomatable (index))
outParameterInfo.flags |= kAudioUnitParameterFlag_NonRealTime; outParameterInfo.flags |= kAudioUnitParameterFlag_NonRealTime;
if (! param->isDiscrete())
const bool isParameterDiscrete = juceFilter->isParameterDiscrete (index);
if (! isParameterDiscrete)
outParameterInfo.flags |= kAudioUnitParameterFlag_CanRamp; outParameterInfo.flags |= kAudioUnitParameterFlag_CanRamp;
if (param->isMetaParameter())
if (juceFilter->isMetaParameter (index))
outParameterInfo.flags |= kAudioUnitParameterFlag_IsGlobalMeta; outParameterInfo.flags |= kAudioUnitParameterFlag_IsGlobalMeta;
// Is this a meter? // Is this a meter?
if (((param->getCategory() & 0xffff0000) >> 16) == 2)
if (((juceFilter->getParameterCategory (index) & 0xffff0000) >> 16) == 2)
{ {
outParameterInfo.flags &= ~kAudioUnitParameterFlag_IsWritable; outParameterInfo.flags &= ~kAudioUnitParameterFlag_IsWritable;
outParameterInfo.flags |= kAudioUnitParameterFlag_MeterReadOnly | kAudioUnitParameterFlag_DisplayLogarithmic; outParameterInfo.flags |= kAudioUnitParameterFlag_MeterReadOnly | kAudioUnitParameterFlag_DisplayLogarithmic;
@@ -859,7 +859,7 @@ public:
else else
{ {
#if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE
outParameterInfo.unit = param->isDiscrete() ? kAudioUnitParameterUnit_Indexed
outParameterInfo.unit = isParameterDiscrete ? kAudioUnitParameterUnit_Indexed
: kAudioUnitParameterUnit_Generic; : kAudioUnitParameterUnit_Generic;
#endif #endif
} }
@@ -867,8 +867,8 @@ public:
MusicDeviceBase::FillInParameterName (outParameterInfo, name.toCFString(), true); MusicDeviceBase::FillInParameterName (outParameterInfo, name.toCFString(), true);
outParameterInfo.minValue = 0.0f; outParameterInfo.minValue = 0.0f;
outParameterInfo.maxValue = getMaximumParameterValue (param);
outParameterInfo.defaultValue = param->getDefaultValue();
outParameterInfo.maxValue = getMaximumParameterValue (index);
outParameterInfo.defaultValue = juceFilter->getParameterDefaultValue (index);
jassert (outParameterInfo.defaultValue >= outParameterInfo.minValue jassert (outParameterInfo.defaultValue >= outParameterInfo.minValue
&& outParameterInfo.defaultValue <= outParameterInfo.maxValue); && outParameterInfo.defaultValue <= outParameterInfo.maxValue);
@@ -885,9 +885,10 @@ public:
{ {
if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) if (inScope == kAudioUnitScope_Global && juceFilter != nullptr)
{ {
auto* param = juceFilter->getParameters().getUnchecked (getJuceIndexForAUParameterID (inID));
const auto index = getJuceIndexForAUParameterID (inID);
auto* param = juceFilter->getParameters().getUnchecked (index);
outValue = param->getValue() * getMaximumParameterValue (param);
outValue = param->getValue() * getMaximumParameterValue (index);
return noErr; return noErr;
} }
@@ -902,9 +903,10 @@ public:
{ {
if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) if (inScope == kAudioUnitScope_Global && juceFilter != nullptr)
{ {
auto* param = juceFilter->getParameters().getUnchecked (getJuceIndexForAUParameterID (inID));
const auto index = getJuceIndexForAUParameterID (inID);
auto* param = juceFilter->getParameters().getUnchecked (index);
param->setValue (inValue / getMaximumParameterValue (param));
param->setValue (inValue / getMaximumParameterValue (index));
return noErr; return noErr;
} }


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

@@ -205,31 +205,29 @@ public:
{ {
info.id = paramID; info.id = paramID;
auto* param = p.getParameters().getUnchecked (index);
toString128 (info.title, param->getName (128));
toString128 (info.shortTitle, param->getName (8));
toString128 (info.units, param->getLabel());
toString128 (info.title, p.getParameterName (index));
toString128 (info.shortTitle, p.getParameterName (index, 8));
toString128 (info.units, p.getParameterLabel (index));
info.stepCount = (Steinberg::int32) 0; info.stepCount = (Steinberg::int32) 0;
#if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE
if (param->isDiscrete())
if (p.isParameterDiscrete (index))
#endif #endif
{ {
const int numSteps = param->getNumSteps();
const int numSteps = p.getParameterNumSteps (index);
info.stepCount = (Steinberg::int32) (numSteps > 0 && numSteps < 0x7fffffff ? numSteps - 1 : 0); info.stepCount = (Steinberg::int32) (numSteps > 0 && numSteps < 0x7fffffff ? numSteps - 1 : 0);
} }
info.defaultNormalizedValue = param->getDefaultValue();
info.defaultNormalizedValue = p.getParameterDefaultValue (index);
jassert (info.defaultNormalizedValue >= 0 && info.defaultNormalizedValue <= 1.0f); jassert (info.defaultNormalizedValue >= 0 && info.defaultNormalizedValue <= 1.0f);
info.unitId = Vst::kRootUnitId; info.unitId = Vst::kRootUnitId;
// Is this a meter? // Is this a meter?
if (((param->getCategory() & 0xffff0000) >> 16) == 2)
if (((p.getParameterCategory (index) & 0xffff0000) >> 16) == 2)
info.flags = Vst::ParameterInfo::kIsReadOnly; info.flags = Vst::ParameterInfo::kIsReadOnly;
else else
info.flags = param->isAutomatable() ? Vst::ParameterInfo::kCanAutomate : 0;
info.flags = p.isParameterAutomatable (index) ? Vst::ParameterInfo::kCanAutomate : 0;
valueNormalized = info.defaultNormalizedValue; valueNormalized = info.defaultNormalizedValue;
} }


Loading…
Cancel
Save