Iterate over AudioProcessorValueTreeState parameters?

How does one iterate over the AudioProcessorValueTreeState, or over its ParameterLayout??

You can use the getParameters(), which is an Array or getParameterTree(), which is a tree, like the name suggests.
Those are methods of the AudioProcessor…

Hi does anyone know how you can iterate through the parameter IDs of parameters added to AudioProcessorValueTreeState? It seems like those two methods @daniel mentioned only give you access to the AudioProcessorParameter superclass, which only gives you access to the parameter name (using getName). I cannot find how I can get access to the getParameterID method of the AudioProcessorParameterWithID subclass of AudioProcessorParameter (which RangedAudioParameter is a subclass of). I’ve tried to figure out how to get the parameter IDs from the underlying ValueTree of AudioProcessorValueTreeState but I cannot work out how to do this. Any ideas?

for (auto* param : processor.getParameters())
{
    if (auto* paramWithID = dynamic_cast<juce::AudioProcessorParameterWithID*>(param))
    {
        auto paramID = paramWithID->getParameterID();
    }
}
1 Like

Yes, unfortunately you have to dynamic_cast. I wish the AudioParameterWithID would be merged to the base class, I don’t think it is anywhere used without.

4 Likes