Accesing AudioProcessorValueTreeState via ValueTree


#1

I use the AudioProcessorValueTreeState (APVTS) as the complete plugin state, i.e., there are additional state parameters additional state parameters added to APVTS::state.

I would like to create for my custom GUI components attachments similar to ffGuiAttachments which synchronize the ValueTree with the GUI component. I would like to avoid distinguishing between AudioParameter and auxiliary state parameters in APVTS when writing these attachments.

Is it possible to directly access/manipulate the AudioParameters in APVTS via the valueTree APVTS::state?

Alternatively, is it possible to synchronize another valueTree (used for the GUI) with APVTS?


#2

Although the parameters are included in the valueTree, I think it is a bad idea to access the values there, since there is a dependency between the values in the ValueTree and the AudioProcessorParameters as seen by the host. There is some bidirectional update mechanism at work, that I would suggest to let it do it’s work.

I also think the AudioProcessorParameters shouldn’t be included in the saved state at all. Since they can be automated, they don’t have a scalar value. The value is dependent on the position in the timeline and updated by the host when playing back or setting the playhead.
The only reason, to put it in regardless is for hosts like the JUCE Plugin Host example, which doesn’t implement automation at all.

I hope that makes sense…


#3

Thanks for the help.

Ok, I thought so.

I’m confused. I thought that I will save the entire APVTS and that’s it. So, saved state should be only non-AudioParameter values, correct? Is this example below correct?

state.createAndAddParameter(paramGain,     "Gain",     "Input Gain",    NormalisableRange<float> (0.0,    2.0, 0.1), 1.0,   nullptr, nullptr);

state.state = ValueTree ("PluginState");

ValueTree guiTree = ValueTree("GuiTree"); // only save GuiTree
guiTree.setProperty("String1", "ok1", &undo);
guiTree.setProperty("String2", "ok2", &undo);
state.state.appendChild(guiTree, &undo);

Is there a way to wrap APVTS for the PluginEditor in a way that I can handle AudioParameters in the same way as GuiParameters?


#4

I’m sorry I confused you. Yes it is correct, you simply save the APVTS.state and done with it. But IIRC if you print it as DBG (state.toXmlString()) you will see that the other values were added magically…