Sending signal/events from audio to GUI thread?

I have been reworking some older code lately, and have been using a similar technique with the Timer for “sending” some types of signal to the GUI. My thoughts at this point are, as a general rule for plugins using AudioProcessorValueTreeState for parameter management:

  1. If you just need Sliders and Buttons to link to parameter values, use the Attachment classes.

  2. If you need other GUI components to update in response to parameter values, make the Editor an AudioProcessorValueTreeState::Listener and trigger those GUI changes in the parameterChanged callback.

  3. If you need GUI components to update in response to audio signals, use this poll-with-a-Timer approach. There are limits on how fast you can update the GUI, and any audio signal is “moving” way faster than a GUI can respond. There is always effectively “downsampling” involved… so you might as well let the GUI set the rate of that, because any faster and it’s just wasted effort.

Any other cases that I’m missing there?

1 Like