I have some properties of my plugin that I want saved and reloaded, but not automatable, so I’m putting them in a value tree that is a child of the audio processor value tree state’s value tree. When I close the plugin interface and re-open it, all of these properties are restored just fine. However, when I save, close, and reopen the DAW project, these properties are not restored.
My audio processor value tree state is restoring most parameters when the project is reopened, but its child with the non-automatable properties is not being restored. I’ve been debugging this for days, and have confirmed that the child tree does have the changed parameters intact when it is saved, but then when it is reloaded, it does not. There are no spots where saved properties are being overwritten, unless it appears in the code below. This happens without the editor being opened, so the problem must be in the processor somewhere.
I’ve been stuck on this for days and have tried everything I could find from tutorials and videos, but nothing has changed. Here is the relevant code:
In the header file, my apvts and the child value tree are initialized as follows:
AudioProcessorValueTreeState valueTree;
ValueTree moduleSettings{ "SETTINGS" };
Value moduleActivatedValue;
Identifier moduleActivatedValueID{ "VISIBLE0" };
In the creation argument of the processor, the property is added to the moduleSettings tree and that tree is added as a child to apvts as follows:
if (!moduleSettings.hasProperty(moduleActivatedValueID))
moduleSettings.setProperty(moduleActivatedValueID, false, nullptr);
moduleActivatedValue.referTo(moduleSettings.getPropertyAsValue(moduleActivatedValueID, nullptr));
if (!moduleSettings.isAChildOf(valueTree.state))
valueTree.state.appendChild(moduleSettings, nullptr);
valueTree.state = ValueTree("valueTreeState");
In getStateInformation() I have the following code. I have also tried the writeToStream methods and other ways of re-ordering this code, but all have the same result:
if (unique_ptr<XmlElement> xml = valueTree.state.createXml())
copyXmlToBinary(*xml, destData);
In setStateInformation(), I have the following code:
if (unique_ptr<XmlElement> xml = getXmlFromBinary(data, sizeInBytes))
valueTree.state = ValueTree::fromXml(*xml);
So does anyone know why my apvts parameters are reloading when a saved project is reopened, but the child tree’s properties are not reloaded? Any help or insight would be greatly appreciated.