Can't get raw parameter value pointer for an AudioProcessorParameter* retrieved AudioProcessorValueTreeState

Hi,

Can you please make AudioProcessorValueTreeState’s methods createAndAddParameter() and getParameter() return a AudioProcessorParameterWithID* instead of just AudioProcessorParameter* ?

This would, for example, to later use AudioProcessorValueTreeState::getRawParameterValue(), by getting the ID of the parameter you created, assuming you have a reference to it, but not to the ID you used to create it.

Thanks,
Dan

1 Like

Sorry, I’m a bit confused about what you want to do. Why would the creation ID be different?

It wouldn’t be - it just makes it easier to get the ID (you don’t have to keep a reference to the ID, once you finished creating the parameter. You can get the ID from the AudioProcessorParameterWithID which would be returned.

Well AudioProcessorParameterWithID is a direct base class of AudioProcessorValueTreeState::Parameter, so you can just do

auto* paramWithID = dynamic_cast<AudioProcessorParameterWithID*> (param);

Of course, and even a static_cast would work. But it’s better if the right
class is just returned.

2 Likes

Yes, fair point. There’s no real reason for it to return the base class pointer when it could return the more specialised one.

(In fact, it’s a good general rule: always return the most specialised subclass where possible. Of course if you’re overloading a virtual method that has a fixed return type, you can’t always do this)

2 Likes

This change has been made on the develop branch.

2 Likes