Ok I’ve been thinking a bit more about this.
If you use a slider as a VU-metre for example. You have 2 possible approaches :
Everytime AudioProcessor::ProcessBlock is called , you calculate an RMS value and set the slider’s value accordingly. Of course you won’t do that from the audio thread but you can use void AsyncUpdater::triggerAsyncUpdate( )and in handleAsyncUpdate(), you call Slider::setValue
Everytime AudioProcessor::ProcessBlock is called , you calculate an RMS value and set an (atomic) variable to this value. Then in another thread, that you call, let’s say 25 times/sec, you call Slider::setValue
Below I assume that Slider::setValue is calling repaint() (that’s what the code seems to do)
In the first case , triggerAsyncUpdate() will push a message to the system message queue to call handleAsyncUpdate(), and then handleAsyncUpdate() will push another message for repaint. So that’s 2 messages by repaint, and we don’t know how often they’re called.
In the second case, you send a repaint message 25 times/sec
So there’s a difference in terms of message thread congestion, system load etc, isn’t it ?
Which approach do you think it’s best ?