Questions about AudioProcessorValueTreeState

Hello to the JUCE team !

Finally, in 2018, I have decided to give a go to the class AudioProcessorValueTreeState, to implement audio plug-ins parameters in my main AudioProcessor class :slight_smile:

So, as I have understood their operating mode, to use one you have :

  • to put it as a public member of the AudioProcessor
  • to declare your parameters using the function “createAndAddParameter”
  • to initialize the state member as a ValueTree with a given name

Here are my first questions :

  • It is stated that you need to provide some lambda functions in the createAndAddParameter function if you want to customize the way the processor converts value to text and vice versa, otherwise the class uses the default implementation. I have observed that if you provide nullptr there and say a given NormalisableRange just before, the DAW only displays the values of the parameters as floats between 0 and 1, even if I provided say a NormalisableRange with values between - 40 and +40. Wouldn’t it make some sense to replace line 74 in juce_AudioProcessorValueTreeState.cpp the instruction AudioProcessorParameter::getText (v, length); with : AudioProcessorParameter::getText (range.convertFrom0to1(v), length);, so that what I did before allows me already to display the correct values in the DAW, using the information I have already provided ?
  • Let’s say I want that my parameters change the value of a flag called “mustUpdateParameters” when they are changed, by the user from the UI, or using automation. How can I do that ? Should I make my AudioProcessor class herit from AudioProcessorValueTreeState::Listener and call “state.addParameterListener(strID, this)” in the constructor for every single parameter, or there is something faster that I have not seen yet ?
  • How I can get the unnormalised value of a parameter from the AudioProcessorValueTreeState ? Do I need to use getText(), the conversion lambdas if I provided one, or something else ?

Thanks in advance !

  1. That sounds sensible.

  2. What are you trying to achieve on a higher level? Could you add a global listener to the APVTS’s state ValueTree member variable?

  3. float* AudioProcessorValueTreeState::getRawParameterValue (StringRef paramID) is the most direct route.


Hello @t0m !

Thanks a lot, ValueTree::Listener and getRawParameterValue were the answers I was looking for :wink:

regarding that

and the related commit :

As mentioned by Fabian in another thread, AudioProcessorParameter::getText() expects a normalised value actually :

Ah, yes. In this particular case it makes no difference as the AudioProcessorParameter::getText() is so simple, but it’s logically incorrect.

I’ll get that fixed. Thanks for pointing it out.

1 Like

Thanks for the fix available on develop branch ! Everything makes sense now this way.