AudioProcessorValueTreeState questions - getRawParameterValue() and modifying parameters programmatically

Three simple and quick questions:

  1. Sometimes the situation arises where one must update some parameter programmatically. What is the “correct” way to do this? Calling AudioProcessorValueTreeState::getParameterAsValue() and using assignment? Or calling AudioProcessorValueTreeState::getParameter() and using assignment? Or something else?

  2. The function AudioProcessorValueTreeState::getRawParameterValue() returns an atomic pointer to a float parameter. The documentation says that this is to read the value of the pointer in realtime w/o overhead. However, for whatever reason, this doesn’t seem to return some kind of const pointer, leaving open the possibility that one could also modify this value. Is being able to modify this something that is intended or is it supposed to be read-only? (I get that you don’t want to modify parameters in realtime in the audio processing thread.)

  3. AudioProcessorValueTreeState::getRawParameterValue() seems to only return a pointer to float. Is there something similar for other parameter types, e.g. int or whatever?

Thank you!

You’d typically want to use juce::AudioParameterFloat, juce::AudioParameterInt, juce::AudioParameterBool, etc.

All audio parameters are of the subtype AudioProcessorParameter and AudioProcessorParameterWithID and their value is always of type float from 0 to 1.

AudioParameterInt and AudioParameterFloat are of subtype RangedAudioParameter that contains a convertTo0to1 and convertFrom0to1 function that helps to scale the value to the range you have set for a parameter.

You can use setValue() or getRawParameterValue() to set a new parameter value in real-time without notifying any listener. This is always a normalized value. You may use convertTo0to1 to set this value.

Thanks, makes sense!