[SOLVED] Plugin params only loaded with GUI

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()))

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?

There is ValueTree::sendPropertyChangeMessage():

1 Like

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


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


but weirdly, this sets the value to either end of the parameter range.

Ok I got it working. The values were set to the limits because I forgot use the conversion function. The working solution is: