I understand the code behind biquads, but I fail to understand how 5 coefficients in a biquadratic formula can isolate frequencies so precisely, especially considering it only takes the last two samples into consideration during the calculations.

How do these biquad filters figure that stuff out? I am no mathematician by any means, hence the ELI5.

Ideally I'm looking for a good analogy similar to 3Blue1Brown's explanation of wrapping a wave around a circle to explain the Fourier Transform.


3 Answers 3


The biquad has feedback so takes all sampled into consideration, not just the last two: the past results are included in each subsequent computation.

Resonant structures will pass a small band of frequencies around the frequency of resonance while rejecting the rest. To see how frequencies can be isolated by resonant structures simply, consider how we can manipulate samples such as adding past results to new incoming samples (which is feedback) will provide for growth: if we are looking to have this growth at an isolated range of frequencies, we can ensure the phase between the output as past samples and what is fed back to the input is such that the samples will be additive while frequencies beyond that range will be destructive.

To further see this start with understanding how an accumulator (adding each new incoming sample to the result of pass additions) is similar to a moving average over all prior samples and how both create a “low pass filter” where the longer we average the tighter the bandwidth will be around DC (DC is an electronics term for a constant voltage, and generally represents a constant signal with frequency equal to 0, thus the average value is "DC") yet with the accumulator we have just one coefficient. A moving average over $N$ samples is the average over the past $N$ samples, so is calling "moving" as we get a new average with every new output. An average is the sum of those $N$ samples divided by $N$, so an accumulator performs the same summing operation (and dividing by $N$ is just an arbitrary scaling).

If we instead rotate that feedback at a certain rate, then instead of having that filter centered at DC, it will be centered at the frequency of rotation. Since the OP already said he understood the Fourier Transform, note that this too would be the computation of the Fourier Transform result for that particular frequency or rotation.

  • $\begingroup$ Your terminology is slightly over my head, so correct me if I'm wrong. Are you trying to say that the biquad (and/or general IIR filters) have a resonant frequency by nature, and we're effectively multiplying the audio signal with that? (i.e. in a simplified way: if resonant multiply by 1, else by 0) $\endgroup$
    – Martmists
    Jul 11, 2021 at 0:27
  • $\begingroup$ Not quite- in my answer - what is the first occurrence of terminology that you don’t understand? Perhaps we can salvage what I wrote …. $\endgroup$ Jul 11, 2021 at 0:44
  • $\begingroup$ I'll just make a list: "resonant structures", "phase shift", "feedback" (in this context), "moving average", "DC" $\endgroup$
    – Martmists
    Jul 12, 2021 at 7:02
  • $\begingroup$ @Martmists got it. I edited to clarify those terms. $\endgroup$ Jul 12, 2021 at 12:19

An IIR band pass filter is similar to a recurrence sine wave generator, or oscillator. It uses the previous 2 ( or N ) outputs to extrapolate the next point of a sine wave, but with decayed amplitude (if the IIR is stable).

A biquad also looks at 3 successive input values and sort of computes how closely these 3 points correlate to a sinewave of the recurrence oscillators frequency. If close in frequency and phase, then some energy is added to the output, if needed, to bring it up to some amplitude related to the input’s estimated waveform amplitude.

If the input kicks the recurrence equation at all the wrong times (opposite to the oscillation phase, etc.) then the recurrence will decay faster than natural, and eventually take on values sufficient to cancel out the input. Or something in between (transition band). A high Q biquad takes a long time to start and stop the recurrence from oscillating. A low Q one might damp out almost immediately, unless the input closely matches a non-decayed version of the recurrence formula’s oscillation result.

So the “knowledge” inside an IIR bandpass filter is basically the recurrence’s sinewave amplitude as inferred by its state variables, which is a result of whether the previous history of input kicks increased or decreased the amplitude of the oscillation (as described by its state variables) to its current value, or got it started (seeded) in the first place.

Also some of the input can leak through to the output, so the output of an IIR can be some mix of its natural sinewave oscillation (in the process of decaying or getting boosted) and the input delayed.


especially considering it only takes the last two samples into consideration during the calculations.

It doesn't. A biquad carries the last two samples of its state, which it takes into account (that's two of the five coefficients), along with the current incoming sample and two previous ones (that's the other three of the five).

Because it takes those last two states into account, the biquad can -- essentially -- respond to the current state of the incoming signal and it's rate. It forms a digital equivalent of a resonant structure -- like a mass bouncing on a spring. Just as a mass on a spring will follow slow motions perfectly but ignore fast motion, so the state of a biquad will follow slow changes in the input perfectly, but will ignore fast changes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.