45 · Digital Audio · Time Domain

Buffers, Blocks & Latency

Audio feels continuous. A computer sees a stream of samples — and very often hands them to an algorithm in groups.

We've already been using this idea

Sampling

A buffer stored a collection of samples so we could play, scrub and interpolate them.

RMS / Detection

We measured more than one sample to describe energy over a short period of time.

Convolution / DSP

Algorithms repeatedly use stored samples, coefficients and chunks of data to calculate an output.

Same samples. New question: how many do we give the processor at once?

1 · One stream → many blocks

The sample rate tells us how many samples exist per second. The block size tells us how many samples are grouped together for a processing call.

48,000 samples/second does not mean 48,000 separate plugin calls/second.

2 · Change the block size

Block duration5.33 ms
Blocks / second187.5
Samples / second48,000
Illustrative workload—

The workload meter is deliberately qualitative: real CPU cost depends on the algorithm, host, hardware and scheduling. The block timing calculations are real.

3 · Where does latency come from?

INPUT SAMPLES
→
COLLECT BLOCK
→
PROCESS
→
OUTPUT

For an algorithm that must wait for a complete block, it cannot calculate that block until the required samples have arrived.

block time = number of samples ÷ sample rate

At 48 kHz, a 256-sample block represents about 5.33 ms of audio. A 1024-sample block represents about 21.33 ms.

Important: this is not a promise that your DAW's total round-trip latency equals one block. Interfaces, input/output buffers, drivers, plugin look-ahead, converters and other stages can add more latency.

4 · Why not make every block enormous?

Smaller blocksLarger blocks
Less time represented by each blockMore time represented by each block
Potentially lower buffering delayPotentially greater buffering delay
More processing calls / scheduling overheadFewer processing calls / less scheduling overhead
Less data available to block-based analysisMore data available to block-based analysis

So block size is a trade-off, not a quality knob.

5 · And why not process exactly one sample at a time?

Some DSP can operate sample by sample. We've already described plenty of it that way:

x[n] → FUNCTION / × / + / z−1 → y[n]

But other jobs make much more sense when the algorithm can inspect a collection of samples. Analysis is the obvious example: one isolated sample cannot tell us whether we're looking at a 100 Hz sine, a 1 kHz sine, a snare transient or a chord.

We need some time before we can ask questions about frequency.

6 · Block size is NOT sample rate

SAMPLE RATE
How densely time is sampled
BLOCK SIZE
How many samples are handed over together

Change 64 samples to 1024 samples and a 48 kHz stream is still a 48 kHz stream. We have changed the packaging, not the underlying sample rate.

Next · Open the other door

We now have a block of samples. What can we learn from it?

TIME DOMAIN
→
BLOCK OF SAMPLES
→
FFT
→
FREQUENCY DOMAIN

We've been showing spectrum analysers for ages. Next, we find out how the computer gets from a waveform through time to a description of frequency.