mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-11 23:54:18 +00:00
Added parameter listener callbacks when a plug-in host changes a parameter
This commit is contained in:
parent
44ec4aee33
commit
107ba1fd69
6 changed files with 102 additions and 19 deletions
|
|
@ -780,12 +780,25 @@ namespace AAXClasses
|
|||
return AAX_SUCCESS;
|
||||
}
|
||||
|
||||
void setAudioProcessorParameter (int index, float value)
|
||||
{
|
||||
if (auto* param = pluginInstance->getParameters()[index])
|
||||
{
|
||||
param->setValue (value);
|
||||
param->sendValueChangedMessageToListeners (value);
|
||||
}
|
||||
else
|
||||
{
|
||||
pluginInstance->setParameter (index, value);
|
||||
}
|
||||
}
|
||||
|
||||
AAX_Result UpdateParameterNormalizedValue (AAX_CParamID paramID, double value, AAX_EUpdateSource source) override
|
||||
{
|
||||
auto result = AAX_CEffectParameters::UpdateParameterNormalizedValue (paramID, value, source);
|
||||
|
||||
if (! isBypassParam (paramID))
|
||||
pluginInstance->setParameter (getParamIndexFromID (paramID), (float) value);
|
||||
setAudioProcessorParameter (getParamIndexFromID (paramID), (float) value);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -856,7 +869,8 @@ namespace AAXClasses
|
|||
if (auto* p = mParameterManager.GetParameterByID (paramID))
|
||||
p->SetValueWithFloat ((float) newValue);
|
||||
|
||||
pluginInstance->setParameter (getParamIndexFromID (paramID), (float) newValue);
|
||||
setAudioProcessorParameter (getParamIndexFromID (paramID), (float) newValue);
|
||||
|
||||
return AAX_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -867,7 +881,8 @@ namespace AAXClasses
|
|||
|
||||
auto paramIndex = getParamIndexFromID (paramID);
|
||||
auto newValue = pluginInstance->getParameter (paramIndex) + (float) newDeltaValue;
|
||||
pluginInstance->setParameter (paramIndex, jlimit (0.0f, 1.0f, newValue));
|
||||
|
||||
setAudioProcessorParameter (paramIndex, jlimit (0.0f, 1.0f, newValue));
|
||||
|
||||
if (auto* p = mParameterManager.GetParameterByID (paramID))
|
||||
p->SetValueWithFloat (newValue);
|
||||
|
|
|
|||
|
|
@ -957,8 +957,19 @@ public:
|
|||
{
|
||||
if (inScope == kAudioUnitScope_Global && juceFilter != nullptr)
|
||||
{
|
||||
const auto index = getJuceIndexForAUParameterID (inID);
|
||||
juceFilter->setParameter (index, inValue / getMaximumParameterValue (index));
|
||||
auto index = getJuceIndexForAUParameterID (inID);
|
||||
auto value = inValue / getMaximumParameterValue (index);
|
||||
|
||||
if (auto* param = juceFilter->getParameters()[index])
|
||||
{
|
||||
param->setValue (value);
|
||||
param->sendValueChangedMessageToListeners (value);
|
||||
}
|
||||
else
|
||||
{
|
||||
juceFilter->setParameter (index, value);
|
||||
}
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1251,6 +1251,19 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void setAudioProcessorParameter (int index, float value)
|
||||
{
|
||||
if (auto* param = getAudioProcessor().getParameters()[index])
|
||||
{
|
||||
param->setValue (value);
|
||||
param->sendValueChangedMessageToListeners (value);
|
||||
}
|
||||
else if (isPositiveAndBelow (index, getAudioProcessor().getNumParameters()))
|
||||
{
|
||||
getAudioProcessor().setParameter (index, value);
|
||||
}
|
||||
}
|
||||
|
||||
void addPresets()
|
||||
{
|
||||
factoryPresets = [[NSMutableArray<AUAudioUnitPreset*> alloc] init];
|
||||
|
|
@ -1303,8 +1316,7 @@ private:
|
|||
const AUParameterEvent& paramEvent = event->parameter;
|
||||
const int idx = getJuceParameterIndexForAUAddress (paramEvent.parameterAddress);
|
||||
|
||||
if (isPositiveAndBelow (idx, numParams))
|
||||
getAudioProcessor().setParameter (idx, paramEvent.value);
|
||||
setAudioProcessorParameter (idx, paramEvent.value);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1450,11 +1462,10 @@ private:
|
|||
{
|
||||
if (param != nullptr)
|
||||
{
|
||||
const int idx = getJuceParameterIndexForAUAddress ([param address]);
|
||||
auto& processor = getAudioProcessor();
|
||||
int idx = getJuceParameterIndexForAUAddress ([param address]);
|
||||
auto normalisedValue = value / getMaximumParameterValue (idx);
|
||||
|
||||
if (isPositiveAndBelow (idx, processor.getNumParameters()))
|
||||
processor.setParameter (idx, value / getMaximumParameterValue (idx));
|
||||
setAudioProcessorParameter (idx, normalisedValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -685,9 +685,24 @@ public:
|
|||
ComponentResult UpdateControlValue (long controlIndex, long value) override
|
||||
{
|
||||
if (controlIndex != bypassControlIndex)
|
||||
juceFilter->setParameter (controlIndex - 2, longToFloat (value));
|
||||
{
|
||||
auto paramIndex = controlIndex - 2;
|
||||
auto floatValue = longToFloat (value);
|
||||
|
||||
if (auto* param = owner.getParameters()[paramIndex])
|
||||
{
|
||||
param->setValue (floatValue);
|
||||
param->sendValueChangedMessageToListeners (floatValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
juceFilter->setParameter (paramIndex, floatValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mBypassed = (value > 0);
|
||||
}
|
||||
|
||||
return CProcess::UpdateControlValue (controlIndex, value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -720,8 +720,16 @@ public:
|
|||
{
|
||||
if (processor != nullptr)
|
||||
{
|
||||
jassert (isPositiveAndBelow (index, processor->getNumParameters()));
|
||||
processor->setParameter (index, value);
|
||||
if (auto* param = processor->getParameters()[index])
|
||||
{
|
||||
param->setValue (value);
|
||||
param->sendValueChangedMessageToListeners (value);
|
||||
}
|
||||
else
|
||||
{
|
||||
jassert (isPositiveAndBelow (index, processor->getNumParameters()));
|
||||
processor->setParameter (index, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1816,9 +1824,12 @@ private:
|
|||
{
|
||||
jassert (isPositiveAndBelow (args.index, processor->getNumParameters()));
|
||||
|
||||
if (auto* p = processor->getParameters()[args.index])
|
||||
if (auto* param = processor->getParameters()[args.index])
|
||||
{
|
||||
processor->setParameter (args.index, p->getValueForText (String::fromUTF8 ((char*) args.ptr)));
|
||||
auto value = param->getValueForText (String::fromUTF8 ((char*) args.ptr));
|
||||
param->setValue (value);
|
||||
param->sendValueChangedMessageToListeners (value);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,7 +246,19 @@ public:
|
|||
// otherwise we get parallel streams of parameter value updates
|
||||
// during playback
|
||||
if (owner.vst3IsPlaying.get() == 0)
|
||||
owner.setParameter (paramIndex, static_cast<float> (v));
|
||||
{
|
||||
auto value = static_cast<float> (v);
|
||||
|
||||
if (auto* param = owner.getParameters()[paramIndex])
|
||||
{
|
||||
param->setValue (value);
|
||||
param->sendValueChangedMessageToListeners (value);
|
||||
}
|
||||
else
|
||||
{
|
||||
owner.setParameter (paramIndex, value);
|
||||
}
|
||||
}
|
||||
|
||||
changed();
|
||||
return true;
|
||||
|
|
@ -1998,9 +2010,17 @@ public:
|
|||
else
|
||||
{
|
||||
auto index = getJuceIndexForVSTParamID (vstParamID);
|
||||
auto floatValue = static_cast<float> (value);
|
||||
|
||||
if (isPositiveAndBelow (index, pluginInstance->getNumParameters()))
|
||||
pluginInstance->setParameter (index, static_cast<float> (value));
|
||||
if (auto* param = pluginInstance->getParameters()[index])
|
||||
{
|
||||
param->setValue (floatValue);
|
||||
param->sendValueChangedMessageToListeners (floatValue);
|
||||
}
|
||||
else if (isPositiveAndBelow (index, pluginInstance->getNumParameters()))
|
||||
{
|
||||
pluginInstance->setParameter (index, floatValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue