My synth plugin is a little on the CPU heavy side and I’ve been wondering if multithreading could help. And considering I have no experience with multithreading in a plugin, I have some questions.
In my synth, there are 2 main CPU-heavy tasks: generating 64 complex waveforms, and then processing the output. I was thinking about having one thread create the 64 waveforms for the size of the audio buffer and put them into a temporary buffer using an AbstractFIFO, and then have the output processing done by the main audio thread.
So, there would be a PrepWaveforms thread, and the main audio thread would expect that the waveforms have already been created, process the output and put it in the audio buffers.
Is that a reasonable way to go about this?
If so, how would I go about making sure the two threads stay in sync? Meaning, how do I guarantee that the PrepWaveforms thread has completed when I’m in the main audio thread?
Am I thinking about this the right way?
PS - It would be great if there was a JUCE multi-threading demo.