Suggested structure for processAudioBlock? (audio plugin)


I’m wondering if there’s any general recommendations for how to structure the processAudioBlock method when creating an Audio Plugin. Let’s assume I’m using sample-by-sample processing as shown in many of the JUCE tutorials.

I ask because I recently built a bit-crusher plugin, but within the for loop that iterates through samples I just directly modify the buffer. Is there any reason to separate between input and output buffer? It intuitively feels correct, but I’d like to know why. Any suggestions are greatly appreciated!


In Juce, there are no separate input and output buffers/channels for the processBlock call. So for example, if your plugin has 4 input and 2 output channels, the buffer provided for the processBlock call will have 4 channels, not 6 channels and the processed output is assumed to be in the first 2 channels of the processBlock buffer.

Understood. And so there’s no potential adverse side-effects that can result from just directly manipulating the buffer? The only issue I can think of would be losing the dry signal, but in that case I could just copy the original buffer into a separate one.

As a sidenote: my confusion came from the fact that I was confusing processAudioBlock, which takes an AudioBuffer as a parameter, with getNextAudioBlock which takes an AudioSourceChannelInfo. I’ll have to go back into the documentation to verify the differences between them.

Yeah if you don’t manipulate the processBlock contents properly, you can lose the original dry signal.

In plugins, you typically should not be dealing with getNextAudioBlock anyway, since that’s a method of AudioSource and not a method of AudioProcessor. (There are few use cases for the AudioSources in plugins.)

What are you actually trying to do?

Noted. I’m building a bit-reducer plugin, and wanted to make sure the structure of my processBlock function was correct.

It is currently working, albeit with some glitchiness, and so I wanted to know if there were general guidelines for building out the processBlock when making a plugin using sample-by-sample processing.

i.e. certain sanity checks I should be doing or other easy things to catch.