FR: AudioProcessorValueTreeState utilities

Now that APVTS is getting some attention, could someone please add the following utilities. I’ve been patching my JUCE code for over a year with this and it would be great to actually have it in the code base. I’m sure someone else would find it useful.

void AudioProcessorValueTreeState::setParameterRange(juce::StringRef paramID, NormalisableRange<float>newRange)
    // my old code use to do this...
    if (Parameter* p = Parameter::getParameterForID (processor, paramID))
        p->range = newRange;

This is useful because I have several parameters that need to change their step values depending on user configuration. Frankly, I’d be happy with just a way to change the step value.

And…please make this public instead of private:
bool flushParameterValuesToValueTree();

The reason I’d like it public: To maintain compatibility with an older version, I need to update parameters in a specific order (because of meta-parameters) rather than just replacing the entire state, and to do that, I need to call flushParameterValuesToValueTree() after updating all the parameters.

Thank you.

1 Like


Your first suggestion makes a lot less sense now that the APVTS can take a much wider range of parameter types (which might not expose a NormalisableRange). You should be able to do the same without modifying JUCE by casting the result of getParameter to a more specific type (probably an AudioProcessorValueTreeState::Parameter in your case).

I’ll have a think about the second suggestion, but I’m reluctant to expose it in it’s current form.