Storing more state info than AudioProcessorValueTreeState

Up until now, all the state information I’ve needed to store has been in my AudioProcessorValueTreeState, and I’ve stored it thusly:

void PluginAudioProcessor::getStateInformation (MemoryBlock& destData)
{
	MemoryOutputStream stream(destData, false);
	mState->state.writeToStream(stream);
}

void PluginAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
	ValueTree tree = ValueTree::readFromData(data, sizeInBytes);
	if(tree.isValid())
	{
		mState->state=tree;
	}
}

However, I’m now working on a plugin that needs to maintain state information beyond just the parameters in my AudioProcessorValueTreeState. For example, I’d like to maintain the address of an audio file so that the plugin can attempt to reload it when the host reopens a session, and other variable values, in addition to my AudioProcessorValueTreeState.

How can I go about doing this?

1 Like

There are lots of ways, but maybe the cleanest is to have a parent ValueTree that contains both the ValueTree you use for your AudioProcessorValueTreeState, and any other ones you need to store other properties.