Sure. I defined a NormalisableRange like this:
NormalisableRange<float> myParamRange = NormalisableRange<float>
(
0.0, 1.0, // ignored in functions below
[this]( float start, float end, float value0To1 ) // convertFrom0To1Func
{
return this->convertMyParamFrom0To1( value0To1 );
},
[this]( float start, float end, float worldValue ) // convertTo0To1Func
{
return this->convertMyParamTo0To1( worldValue );
},
[this]( float start, float end, float valueToSnap ) // snapToLegalValueFunc
{
return this->snapMyParamToLegalValue( valueToSnap );
}
);
// Need these to be 0, so that the attachment causes the control to use this NormalisableRange.
myParamRange = 0.0;
myParamRange = 0.0;
//
pMyParam = parameters.createAndAddParameter( myParaMID,
"My parameter",
{},
myParamRange,
0.0f, // default
nullptr,
nullptr,
false, // not meta
false, // automatable
true, // discrete
AudioProcessorParameter::genericParameter,
false ); // boolean
parameters.addParameterListener( myParamID, this );
And in those functions, I simply convert the values by multiplying or dividing by the number of items currently in the associated drop-down (minus 1).
