Hi all,
I’m using an AudioProcessorValueTreeState to store parameters and a couple of properties.
I want to hide the information stored in the properties from the user, but I have some listeners to respond to changes of some properties.
To save and load the state, I do this.
void PluginProcessor::getStateInformation (MemoryBlock& destData)
{
auto state = parameters.copyState();
std::unique_ptr<XmlElement> xml (state.createXml());
copyXmlToBinary (*xml, destData);
}
copyState() doesn’t copy the listeners, which I understand to some extend.
Is there a way to store and recall the state without losing the listeners?
I am of course adding listeners in my components. However copying the state doesn’t copy the listeners that where added (Value and Listeners)
The user is the person using the plugin Sorry for being unclear here… I guess what I wanted to say was, that I’m not using regular parameters because then the values I’m storing will show up in the automation dialog in the DAW, which doesn’t make sense in this case.
That’s unfortunate… I just started writing some code that was about to go this same route
You may be able to do your listener setup in a function so that you can call it from multiple places.
This way you could call it once in the GUI constructor, and then whenever setStateInformation() is called you could trigger the function (I guess via async update, can’t remember what thread these state methods happen on…) again if the editor is open
Are you attaching listeners to the tree itself or are you using something like juce::ValueTree::getPropertyAsValue()? I’m using the later in my new code but haven’t gotten to state/saving loading myself
iterate your old tree, grab all of the properties that have listeners,
then iterate the new state, go through the properties that match, and re-add listeners?
I don’t know, maybe that’s garbage. sounds like you might need to rethink your model to get around this…