DSP Toolbox · New Primitive

Measure & Compare

So far we have mostly changed audio. Now we ask a different question: how can the computer know what the audio is doing?

audio → MEASURE → PEAK / RMS / ENVELOPE → COMPARE → CONTROL
The key idea: we can split the signal. One copy remains audio. Another copy becomes a detector/control path.

1. Why can't we just use the waveform?

Audio is bipolar. A large negative sample is not “quiet”; it is simply the other half of the waveform.

+0.8 0 −0.8 0 +0.8

If we want to describe magnitude, polarity gets in the way.

So one simple detector starts by making magnitude positive:

d[n] = |x[n]|

For RMS, squaring does the same job in a different way:

(−0.8)² = (+0.8)² = 0.64
Important: the audio path stays bipolar. We are creating a unipolar control representation of the audio, not listening to the rectified signal.

2. One signal — several measurements

Choose a source, play it, and watch Peak, RMS and Envelope respond to the same signal in different ways.

−12 dB
100 ms
20 ms
250 ms
Peak−∞ dBFSlargest instantaneous magnitude
RMS−∞ dBFSenergy over a time window
Envelope−∞ dBFSsmoothed control signal
READY · no normalization applied

3. See the signal become control information

WAVEFORM · bipolar audio
x[n]

4. RMS — why do we need it?

For a perfect sine, there is a shortcut:

RMS = Peak / √2 ≈ Peak × 0.707

But real music does not have a fixed Peak→RMS multiplier. A transient-heavy signal can have a high peak and a much lower RMS. So for arbitrary audio we actually perform:

SQUARE
→
MEAN
→
ROOT
RMS = √( (1/N) Σ x[n]² )
Peak asks: “what was the largest excursion?”
RMS asks: “how much signal energy was present across this window?”

5. Envelope follower — turn level into a moving control signal

Peak and RMS are measurements. An envelope follower makes a continuously changing control signal that can follow the audio more quickly or more slowly.

magnitude → smoothing → ENVELOPE

Attack controls how quickly the detector rises. Release controls how quickly it falls.

This is where detection starts becoming musically useful: we are deciding how fast the machine should react.

6. Compare it with a threshold

Now give the computer something to compare the measured envelope against. The blue line is a compressor-style envelope trace; the dashed line is the threshold.

20 ms
250 ms
−18 dBFS

This is the same source and detector as Section 2 — the transport is repeated here so you can work directly with the threshold.

BELOW
BELOW THRESHOLD
if envelope > threshold → TRUE else → FALSE
We now have a decision. Audio has become control information.

7. Use the signal to control the signal

┌──── AUDIO PATH ───────────────→ INPUT ── SPLIT ───┤ └──── DETECTOR / SIDECHAIN ─────→ |x| / RMS / envelope ↓ COMPARE ↓ CONTROL

In digital audio, the detector copy can be effectively perfect and trivial to route. The original audio remains untouched until we deliberately use the control signal to change something.

This is the detector/sidechain architecture. First the signal can control itself. Later, a completely different signal can feed the detector.
What did we just build?

The decision-making half of a dynamics processor

Measurement / comparisonWhat it can become
Envelope above threshold?Gate / expander decision
How far above threshold?Compressor / limiter gain calculation
Fast change in envelope?Transient detector
Slow level estimate?Automatic gain control / levelling
NEXT: MEASURE → COMPARE → calculate gain → × AUDIO

And there is our old friend again: multiplication.