Hey there!
I’m currently working on a command-line host for audio plugins using JUCE’s AudioPluginInstance to host VST2, VST3 and AU plugins without any GUI.
Within this context, I need to load the plugin’s state from an XML file. I want to use AudioProcessor::setStateInformation() for that, but when I call setStateInformation on my AudioPluginInstance, the call doesn’t seem to go through. Debugging yields that the setStateInformation() method is indeed not called and that I’m leaking 2 instances of class MessageListener.
I read through all other related posts, but couldn’t apply them to my own issue.
Here’s a minimum version of the components I’m using for reproducing this:
In the constructor of my plugin, I write my xml-file from the ValueTree of the plugin like this:
parameters_.getParameter("gain")->setValueNotifyingHost(0.125f);
auto state = parameters_.copyState();
std::unique_ptr<XmlElement> xml (state.createXml());
juce::File outputFile(xmlFilePath);
xml->writeTo(outputFile, {});
With the setStateInformation() method of the plugin looking like this:
void NewProjectAudioProcessor::setStateInformation(const void* data, int sizeInBytes)
{
std::unique_ptr<XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes));
parameters_.replaceState(ValueTree::fromXml(*xmlState));
}
My command-line application then hosts the pugin using JUCE’s AudioPluginInstance and calls setStateInformation() on the plugin like this:
juce::File outputPresetFile(xmlFilePath);
juce::XmlDocument xmlDoc(outputPresetFile);
auto xml = xmlDoc.getDocumentElement();
juce::MemoryBlock block;
pluginInstance_->copyXmlToBinary(*xml, block);
pluginInstance_->setStateInformation(block.getData(), block.getSize());
When I run the above, I’m not arriving at my breakpoint set in the setStateInformation() method of the plugin. Executing until the end yields the following output:
JUCE v5.4.7
JUCE Assertion failure in juce_MessageManager.cpp:39
*** Leaked objects detected: 2 instance(s) of class MessageManager
JUCE Assertion failure in juce_LeakedObjectDetector.h:90
Is the leaking connected to setStateInformation not being called? Does anyone know how to correct my leaking MessageManager? Or am I missing something else entirely?
I’d appreciate any hint on what could be going wrong here!
Thanks,
Simon