After saving a project in the DAW and loading it again, my plugin will only restore its internal state after I open the GUI. Before it behaves like it was initialized.
I set the state in setStateInformation() like so:
std::unique_ptr<XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes));
if (xmlState.get() != nullptr) {
if (xmlState->hasTagName(m_value_tree.state.getType()))
m_value_tree.replaceState(ValueTree::fromXml(*xmlState));
}
I’m using listeners to the audiotree to set values in my DSP code, but my guess is that replacestate() will not notify the listeners.
Is there a way to notify the listeners, or maybe even make every single parameter act like it was changed, even though it wasn’t?
Thanks for your answer! The proposed solution works just fine for everything that is not an audioparameter. However, I found that triggering audioparameters on the ValueTree (not on AudioProcessorValueTreeState) doesn’t retrigger the parameter listeners. The problem here might be that I don’t know how the parameters are even stored on the ValueTree. For example, calling
m_value_tree.state.getNumProperties();
returns 0, so it seems to me the audio params are stored in a different way.
I also tried to set the values manually by calling