Mixing Xml and Binary data in MemoryBlock for Saving Plug-in Info

Hi all,

 At present I have a plug-in with a  ValueTree holding my plug-in state (parameter values, etc). In getStateInformation() I save my plug-in state as follows

ScopedPointer<XmlElement> xml(myValueTree.createXml());
copyXmlToBinary (*xml, destData);

I then retrieve the ValueTree in setStateInformation() as follows:

ScopedPointer<XmlElement> xmlState (getXmlFromBinary (data, sizeInBytes));
ValueTree newTree = ValueTree::fromXml(*xmlState);

This works fine. However, I also have an audio buffer (which here, I will refer to as 'x') which I would like to save with the plug-in state. In theory, in getStateInformation() I could call:

destData.append(x, sizeof(x[0]) * lengthOfArray);

to add my array to the MemoryBlock.

But how would i then retrieve this? Does the getXmlFromBinary() function allow me to get the Xml if the memory block isn't entirely Xml? If not, how can I work out what the offset of the xml data is so that I can retrieve my array data?

My final question - to which the answer is "it depends on the host" but I will seek some wisdom here anyway - does anyone know if there is a size limit on the MemoryBlock stored by the host (e.g. Live, Logic...)? I would like to store small (< 10 second audio files) but I need to know if I put an upper limit on this based on anyone's experience.

Thanks in advance for any help!


Don't really know about the second question, but concerning the first one: you could create a MemoryBlock that is filled with the data of the sample buffer, and then use the to64BitEncoding method to create a binary string out of it. Which you can then add as an attribute to your xml element.