New AudioProcessorValueTreeState behavior


#1

With the new JUCE version (5.4) you can add parameters to the APVTS by the constructor or the new createAndAddParameter() function. But the latter only works if the state is not initialized and that means I need to use the soon to be deprecated constructor to be able to add parameters one by one. So what is the intended way if I don’t want to use the APVTS constructor to set up the whole parameter structure, but want to add them one by one?


#2

Have you read this thread? AudioProcessorValueTreeState Improvements
I’m guessing you want to add some parameters programmatically? There is a reply from Tom in that thread which will help you if that’s the case.


#3

Thank you, I didn’t see that thread, and actually I can solve it by programmatically adding stuff right now. I was mostly wondering about the intention as if soon there will be only one constructor for the class (as one of the two will be depreceated soon) and that will be the only way to add parameters to the class, that would be strange. I just wanted to prepare for this change not using a constructor that will be deprecated soon but I need a way to add parameters by program and not constructor so my only chance is to use the soon to be deprecated constructor.


#4

Could you give some more details? What can’t you do without using the deprecated constructor?


#5

Obviously everything can be solved, but my problem can be boiled down to the fact that I have a general parameter handling way and when I set up 50-100 parameters I like to define the functionality for a certain parameter at one place (including usability and UI related stuff too). But if I can’t call the rawParameterValue() function before calling the Constructor (with all the parameters already added to a Layout list) then I need to separate the construction of the parameters from my other parameter definition code. Again, I know the world won’t end, just I was wondering why it’s important to ditch the add-one-by-one function from the class.

On the other side, it was a bit confusing that there is a new version of createAndAddParameter() without any future deprecation notice, but if the non-state-initializing constructor will be deprecated, then this function will be useless too, as the main constructor initializes the state even if you pass an empty layout to it and that means you can’t add new parameter with this function.

Maybe a solution would be not to initialize the state if the layout is empty? So then one counstructor could be enough, but we still could have the one-by-one functionality.


#6

Hi tom. Here is a post (with a code example) about something I can’t do without the deprecated constructor as far as I can see : AudioProcessorValueTreeState Improvements


#7

One of the motivations behind this change is to get rid of the two stage initialisation process where JUCE users need to know that you must set the state member after adding all your parameters.

@lalala I’ve just answered in the other thread.

Another motivation was to kill off the old form of createAndAddParameter where the argument list was forever growing. The new form of createAndAddParameter is immune from the same form of feature-creep and is a convenient way to allow time-poor JUCE users to migrate to the latest version. Ultimately I’d like to see that method deprecated too, but we’re changing things slowly so that we can take on board people’s feedback too.