Updating GUI upon preset load in plugins

From the AudioParameterTutorial I’ve learned how to write and read AudioParameters to/from plugin preset files using XML.

The methods used for this are already predefined in my AudioProcessor subclass when I create a JUCE Audio Plugin project.

According to the Plugin Tutorial part 2, the Processor should be viewed as the parent of the Editor:

“When passing information between these two it is best to consider the processor as the parent of the editor.”

Also the Editor should be responsible for getting and setting data in the Processor:

“It is the editor’s job to set and get information on this processor thread and not the other way around.”

Since the methods proposed for writing/reading preset data are located in the Processor and since the Processor holds no reference to my Editor (an AudioProcessorEditor subclass setup by the project) I find no reasonable way to notify the Editor so it can update it’s GUI with new parameter values.

So how is this supposed to work? Is the Editor notified some other way behind the scenes when presets are read and if so which method do I override to update the GUI?

Or is this supposed to be done in an enirely different manner?

Also how can the Processor be viewed as parent to Editor without holding it’s reference? Seems like I’m missing some vital aspect on how plugins are set up in the Projucer plugin template.

You should have your GUI set up so that it automatically updates its state. (This is not important only for loading presets but also for keeping the plugin’s GUI updated when the host is automating the plugin’s parameters.)

The old way in Juce was to have a Timer in the editor whose callback would go through the components, check if their current value is different from the current one in the processor and if so, then update the component.

The modern suggested way is to use AudioProcessorValueTreeState and its related component attachment classes. The attachments will automatically keep the components updated based on the processor’s parameters. Unfortunately this method only covers Sliders, ToggleButtons and ComboBoxes as the attached components. If you have specialized custom components, you will need to write your own attachment class (or similar functionality) or revert to the legacy method described above.

OK, thank you. This was a little bit above my head for now but think I get the general idea. I’ll get back to this when I’ve read more tutorials.

This tutorial explains the AudioProcessorValueTreeState and the attachments :

https://docs.juce.com/master/tutorial_audio_processor_value_tree_state.html

Thanks.