Would it be possible to make some refinements to the Juce AudioProcessor and AU Wrapper classes. Audio Unit parameters don’t have to be in the 0-1 range and can provide more detailed information to the host (such as min, max etc.) so they can be displayed correctly when automated or used in generic UIs. The changes are minimal and should not affect user code as they have default implementations which just call the standard get/set parameter etc.
I believe VST 3 and possibly 2.4 have some sort of similar concept when scaling parameters from normalised to plain values. Although I haven’t looked into VST fully this system could perhaps be fitted into the VST Wrapper as well. Is anybody else doing a similar thing?
The changes are as follows:
AudioProcessor.h
//==============================================================================
/** Some hosts may call this if they support parameter ranges outside of the
0 - 1.0 range. This should return the value of your full-scale parameter.
By default this just returns your normalised parameter by calling getParameter().
*/
virtual float getScaledParameter (int parameterIndex);
/** Some hosts may call this if they support parameter ranges outside of the
0 - 1.0 range. The newValue argument could be any number so you should allow
for this in your code.
By default this just sets your normalised parameter by calling setParameter().
*/
virtual void setScaledParameter (int parameterIndex, float newValue);
/** Sets a full scale parameter and notifies the host, similar to
setParameterNotifyingHost().
*/
void setScaledParameterNotifyingHost (int parameterIndex, float newValue);
/** Some hosts may call this if they support parameter ranges outside of the
0 - 1.0 range. This should return the minimum value your parameter can have.
*/
virtual float getParameterMin (int parameterIndex);
/** Some hosts may call this if they support parameter ranges outside of the
0 - 1.0 range. This should return the maximum value your parameter can have.
*/
virtual float getParameterMax (int parameterIndex);
/** Some hosts may call this if they support parameter ranges outside of the
0 - 1.0 range. This should return the default value your parameter has.
*/
virtual float getParameterDefault (int parameterIndex);
AudioProcessor.cpp
float AudioProcessor::getScaledParameter (int parameterIndex)
{
return getParameter (parameterIndex);
}
void AudioProcessor::setScaledParameter (int parameterIndex, float newValue)
{
setParameter(parameterIndex, newValue);
}
void AudioProcessor::setScaledParameterNotifyingHost (int parameterIndex, float newValue)
{
setScaledParameter (parameterIndex, newValue);
sendParamChangeMessageToListeners (parameterIndex, newValue);
}
float AudioProcessor::getParameterMin (int parameterIndex)
{
return 0.0f;
}
float AudioProcessor::getParameterMax (int parameterIndex)
{
return 1.0f;
}
float AudioProcessor::getParameterDefault (int parameterIndex)
{
return 1.0f;
}[/code]
juce_AU_Wrapper.mm:
[code]line 417:
outParameterInfo.minValue = juceFilter->getParameterMin (index);
outParameterInfo.maxValue = juceFilter->getParameterMax (index);
outParameterInfo.defaultValue = juceFilter->getParameterDefault (index);
line 437:
outValue = juceFilter->getScaledParameter ((int) inID);
line 452:
juceFilter->setScaledParameter ((int) inID, inValue);
Audio Units also have a AudioUnitParameterUnit enum which is used by the host to display and map values accordingly but I’m still thinking of an elegant place to put something similar.
Anyway, adding this would save me having to patch Juce every time I update and could be useful to others. Is anybody doing something similar in their plugins?