AudioProcessorValueTreeState initialization


IIUC, after creating and adding all desired parameters to an AudioProcessorValueTreeState, its state instance variable must be set to some valid state, and done so explicitly, e.g. treeState.state = ValueTree("MyPlugin");.

Otherwise, plugins won’t instantiate correctly, because the state is expected to be a valid one, and AudioProcessorValueTreeState's default ctor doesn’t initialize it as one. In fact, the createAndAddParameter method expects the state to be invalid, as commented there:

“All parameters must be created before giving this manager a ValueTree state!”

The thing is, it seems to me that it isn’t clear from the public documentation of AudioProcessorValueTreeState that the state needs to be set to a valid one, manually, once all the parameters have been added. Doesn’t it make more sense to either a) document it, or better b) provide a public method to call for when you’re done creating parameters which creates a valid state for you, instead of requiring you to modify the state member? (whose documentation implies you may make additions to it, but doesn’t say that you should modify it).


Yeah I think it might be worth clarifying this in the docs. Thinking back I’m sure the first time I used AudioProcessorValueTreeState this caught me out because I didn’t have prior experience using ValueTree.


Yet another bumpy bump


I’ve added an extra sentence to the docs on the develop branch.


Thanks! I suggest also modifying the documentation of the state variable, so it’s clear when you look at it that you should set it to something, not just can.


I’ve added that the the develop branch too.