Plugin examples that calculate parameters outside of the processBlock() function?

Hi all,

I’m working on some new plugin stuff, and I’m moving away from my older code base towards something that is more up to date Juce-wise. In the past, I used getParameter/setParameter to calculate my parameters, and the parameter calculations would end up in their own thread.

The current Juce plugin examples and tutorials, as far as I can tell, all calculate the parameters inside the processBlock() function. That seems like the parameters would be calculated in the same thread as the audio code, at the block rate of the DAW, which could get problematic for heavier calculations.

Are there any example plugins that would serve as a good example for how to calculate parameters in a thread-safe way in 2020?


Sean Costello

Sorry I don’t have any examples, but I’m attempting to solve the same problem. The way I see it is to have a calculation done elsewhere in the plugin/app, and that the parameter (atomic) is updated through a different thread. At least the bulk of the calculation can be done outside in a non-RT thread, like if generating wavetables or something of the like, and once ready, it updates the atomic parameter value.

Is this what you’re thinking? I’ll be happy to share code on this so we can help each other out.

There are only two options, as I see it:

  • asynchronous: the change is applied any time later -> sucks when bouncing
  • synchronous: if it is too heavy to compute, live is a problem

If the host supplies the isNonRealtime() flag correctly, having both variants at hand and use the appropriate one could be a solution?

Maybe there is another way to make it fast enough to be synchronous? E.g. having data prepared in a table, or any other way?