AudioParameterFloat and AudioProcessorValueTreeState

I was looking at the new tutorials and really like the new way to access parameter values. Currently I’m using a AudioProcessorValueTreeState and add my parameters with createAndAddParameter(). The only problem I have is that I can’t cast the AudioProcessorParameter* from createAndAddParameter() to a AudioParameterFloat*. I tried static_cast. The cast works, but the value and range are set to zero.

Am I doing something wrong?

The AudioProcessorValueTree class uses it’s own internal parameter class (AudioProcessorValueTreeState::Parameter) so casting to an AudioParameterFloat will mess things up, all the listener logic etc. These classes are meant to be used separately for different approaches.

Why the need to cast ?

I would like to use the new way to access parameters. Like:
AudioParameterFloat* cutoff = new AudioParameterFloat(…);

Right now I call the getRawParameterValue() Function of the AudioProcessorValueTreeState class.

Does it not make sense to have your processor inherit from AudioProcessorValueTree::Listener and then use the listener callback ?

void MyProcessor::parameterChanged(const String& paramID, float newValue)
    if (paramID == "filterCutoff")

Makes sense. Thanks!

Very welcome. :+1: