The problem is that once the replaceState() call happens, I then need to set all of my synth parameters based on the new data we just loaded. Now, my processor is also a AudioProcessorValueTreeState::Listener so if I could just get parameterChanged() to be called for all of my parameters, that would solve my problem, but alas replaceState() does not seem to trigger the parameterChanged() listeners.
My solution is to insert this code into the function above:
How are people setting their plugin settings after loading parameters via XML and calling replaceState? Is there some magic other way?
Is there some way to get replaceState to trigger parameterChanged messages?
If not, how can I parameterChanged messages for all parameters at once?
Or, assuming all of the work is correct…is there some clever way to iterate over all the parameters in a AudioProcessorValueTreeState without doing what I did above?
obviously just need a bit of adaptation to take a File instead of a string, but this Just Works™️ without any need for any other hoops to be jumped through.
I take a string so that I can either load from a file (using file.loadFileAsString() for user presets) or I have a bunch of built in presets defined using:
The first method is not thread safe so you shouldn’t use that in places like setStateInformation which could be called on the audio thread.
All replaceState does is replace parameters.state with the ValueTree::fromXml (*xmlState) in the second line of the implementation, so I’m a little surprised that changes anything.
Oh, really? Didn’t realize that about the thread safety. I’m also not sure why setting the state directly (instead of using replaceState) should change anything.
I guess that line in replaceState is what makes the difference, also time to fix my code using that instead. I can’t remember where I learned the replacing state directly from, perhaps old JUCE examples?
I have the same issue of replaceState not sending a change message to corresponding attached AVPTS listeners. parameters.state = ValueTree::fromXml (*xmlState); does not notify the listeners, nor does replaceState. Have you all found the correct way to do this?