Hello JUCErs
We’ve made some changes to the AudioProcessorValueTreeState class:
The highlights are:
- It’s now possible to have an APVTS manage a wide range of different parameter types, including JUCE’s built-in
AudioParameterBool,AudioParameterChoice,AudioParameterFloatandAudioParameterIntclasses. - You can avoid the cumbersome two-stage initialisation process, where you first add parameters and then assign the ValueTree state, with a new constructor that does both operations.
To make this happen we’ve introduced a new generic AudioProcessorParameter type, RangedAudioParameter (derived from AudioProcessorParameterWithID), that defines most of its behaviour via a NormalisableRange. The AudioProcessorValueTreeState can manage any type derived from RangedAudioParameter, which now includes JUCE’s built-in parameter types, and opens it up to user-defined parameter types too.
Here’s an example of the new best practice:
YourAudioProcessor()
: apvts (*this, &undoManager, "PARAMETERS",
{ std::make_unique<AudioParameterFloat> ("a", "Parameter A", NormalisableRange<float> (-100.0f, 100.0f), 0.0f),
std::make_unique<AudioParameterInt> ("b", "Parameter B", 0, 5, 2) })
You can also use this approach to manage AudioProcessorParameterGroups; the ParameterLayout parameter of the AudioProcessorValueTreeState constructor is variadic and able to take an arbitrary sequence of RangedAudioParameters and AudioProcessorParameterGroups of RangedAudioParameters. There’s also an iterator-based constructor that will allow you to create an AudioProcessorValueTreeState from a previously-populated container.
We’re also taking the opportunity to remove some of the bloat from the AudioProcessorValueTreeState interface. The AudioProcessorValueTreeState::createAndAddParameter function has been deprecated. This function was slowly increasing in complexity as we added features to the AudioProcessorParameter classes, with no obvious way to avoid repeating ourselves in code. The replacement function takes a std::unique_ptr<RangedAudioParameter> instead, bypassing the large number of function parameters required. Since this method has been the only way to actually add plug-in parameters to an AudioProcessorValueTreeState, this deprecation will affect everyone. However, there is a low-effort, drop-in replacement available. Code that previously looked like
createAndAddParameter (paramID1, paramName1, ...);
can be replaced with
using Parameter = AudioProcessorValueTreeState::Parameter;
createAndAddParameter (std::make_unique<Parameter> (paramID1, paramName1, ...));
where AudioProcessorValueTreeState::Parameter is a RangedAudioParameter subclass that reproduces the behaviour of the old, internal APVTS parameter type.
Please give the new functionality a try and report back if you run into any difficulties!

