General DSP: Buffers vs Blocks vs Context

I’ve been reading into the juce::DSP tools today and was curious about the differences between Buffers, Blocks, and Context. I understand buffers to be arrays of audio samples, but how do those relate to Blocks and Contexts in terms of DSP processing.

Reading the documentation it seems like Blocks are functionally the same as buffers, but in DSP code you usually convert a Buffer into Blocks to do processing. Am I missing something?

Any thoughts appreciated, thanks!

They are indeed the same. Just that the AudioBlocks were added later.

In general:

  • AudioBuffers are usually owning audio data with a few exceptions
  • dsp::AudioBlocks usually don’t own audio so they can be copied around (AudioBuffers would allocate, if you did that)
  • dsp:ProcessorContext is a wrapper how to supply the input and output to a dsp::Processor in a single argument. And by choosing ProcessContextReplacing and ProcessContextNonReplacing the processor can implement those two versions differently.
1 Like

That clears it up, thanks!