I have AudioProcessorValueTreeState for the regular plugin paramters which works as expected. I’m wanting to add various data to the saved info (at this stage just some strings).
This is the example I found and am trying to work with:here
in PluginProcessor.h I have:
public: .. Value nonParmStringVal; static Identifier myNonParmStringID; Value anotherVal; static Identifier anotherStringID;
In PluginProcessor.cpp
> Identifier AudioPluginTemplateAudioProcessor::myNonParmStringID("mynonparmstring"); > Identifier AudioPluginTemplateAudioProcessor::anotherStringID("anotherstring"); > //============================================================================== > AudioPluginTemplateAudioProcessor::AudioPluginTemplateAudioProcessor() : parameters(*this, nullptr, Identifier("APVTSTutorial"), > { > std::make_unique<AudioParameterFloat>("gain", // parameter ID > "Gain", // parameter name > 0.0f, // minimum value > 1.0f, // maximum value > 0.5f), // default value > std::make_unique<AudioParameterBool>("invertPhase", // parameter ID > "Invert Phase", // parameter name > false) // default value > })
{
phaseParameter = parameters.getRawParameterValue("invertPhase");
gainParameter = parameters.getRawParameterValue("gain");
parameters.state.setProperty(myNonParmStringID, var("init"), nullptr);
nonParmStringVal.referTo(parameters.state.getPropertyAsValue(myNonParmStringID, nullptr));
parameters.state.setProperty(anotherStringID, var("init2"), nullptr);
anotherVal.referTo(parameters.state.getPropertyAsValue(anotherStringID, nullptr));
}
The getstate and setstate have xml file output for diagnostic purposes:
void AudioPluginTemplateAudioProcessor::getStateInformation (MemoryBlock& destData) { //to->DAW File file("D:/toDAW.xml"); auto state = parameters.copyState(); std::unique_ptr<XmlElement> xml(state.createXml()); copyXmlToBinary(*xml, destData); if (xml->writeToFile(file, "")) DBG("toDAW written"); else DBG("toDAW not written"); }
void AudioPluginTemplateAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{ //from<-DAW
File file("D:/fromDAW.xml");
std::unique_ptr<XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes));
if (xmlState.get() != nullptr)
if (xmlState->hasTagName(parameters.state.getType())) {
parameters.replaceState(ValueTree::fromXml(*xmlState));
if (xmlState->writeToFile(file, "")) DBG("fromDAW written");
else DBG("fromDAW not written");
}
}
Finally loading and saving a DAW session results in the following XML files:
“toDAW.xml”:
<?xml version="1.0" encoding="UTF-8"?>
<APVTSTutorial mynonparmstring="init" anotherstring="init2">
<PARAM id="gain" value="5e-1"/>
<PARAM id="invertPhase" value="0"/>
</APVTSTutorial>
and “fromDAW.xml”:
<?xml version="1.0" encoding="UTF-8"?>
<APVTSTutorial>
<PARAM id="gain" value="4.599999785423279e-1"/>
<PARAM id="invertPhase" value="1"/>
</APVTSTutorial>
I don’t know much about xml but in the “toDAW.xml” the attribute value pairs seem weird to in sequence without delimiters like that.
Also the attributes aren’t appearing in the output file so something basic is missing…
I just haven’t seen any working examples of what must be basic stuff in the overall scheme of things, so I’d really appreciate any input,
thanks