Maybe this is too subjective, but I feel like there are some major classes you aren’t made aware of in the tutorials (although I haven’t read them all). So my top beginner tips would be “Check the docs for AudioProcessorValueTreeState, Parameter Attachments, AudioBlocks, OwnedArray for GUI components and ComponentSafePointer/WeakReference”.
If that’s too much/too debatable, maybe just ‘use ComponentSafePointer with callAsync (not ‘this’)’.
In fact, may I suggest a code example using callAsync should be in the docs of ComponentSafePointer?
Another one I use commonly is:
“in a plug-in, treat the coupling between processor and editor as if you could have 0, 1 or even TWO editors looking at the same processor”.
Keeping this mental model, it’s easy to discern where a piece of data should go, whether in the editor or in the processor.
“If I change this value, do I want it to be reflected in all editors looking at this processor (-> belongs to processor), or just in the one editor that I’m acting on (-> belongs to editor)?”. The former is the typical case of audio parameters, for the latter, one example could be the plug-in window size, if it’s resizable.
This also makes it easier to reason about:
the notifications needed for notifiying to editors that a value in the processor has changed.
what values the editor should read from the processor in order to display the UI in the correct state when you open it the first time.
Well, more generally the editor must work in “pull” mode… the processor should never “push” any information to the editor. You could actually have even more than one editor pulliing information from the same processor.
Instead of using timers to update the UI, I prefer using the changeBroadcaster or even the actionBroadcaster where the editor is set as a listener (and sometimes even as a broadcaster itself), so everytime something changes in the processor (Midi or Automation cause a parameter change), the change message is sent to all listeners, and listeners asynchronously pull new data from the processor and update their elements.
farbot is a useful library to ensure realtime-safe reading/writing to/from an audio thread. If you need to transfer data from the processor to the editor, you’ll need to use some of these patterns.