ValueTree & AudioProcessor::getStateInformation()

I’m trying to use a ValueTree to store complex objects in getStateInformation(). However I see there is an helper function called copyXmlToBinary(), but there isn’t anything to copy a ValueTree to destData.

How should I manage to store in destData a ValueTree with objects? Should I convert it to XML (does it works with valuetrees that have objects?)? Or is there something that I could do directly, without workarounds?

If your valuetree is using dynamicobjects, then there’s no way it can be converted to any kind of representation, you’d need to handle them specially. But if it doesn’t use them, then there’s no harm in just converting it to XML and saving that, or to be more efficient, just convert it directly to binary and save that as the state.

That’s the case. Please, could you be a little more specific about “handle them specially”? How would you save several MidiMessageSequence and other objects in destData?

It depends entirely on what your data is - if you’re using a bunch of miscellaneous c++ objects, then it’s your job to figure out the best way to store them. There’s no way the ValueTree or any other class can do that automatically for you.

Ok - I thought that those DinamicObjects would be converted to binarys with ValueTree::writeToStream ()


No, they contain references to function callbacks, so can’t be automatically saved.