Low Shelf Filters


Digital Biquad Filtering

Brief:


A second-order biquad low-shelf filter boosts or attenuates frequencies below a specified cutoff point while leaving higher frequencies relatively unaffected. It uses two poles and two zeros to shape the transition between the affected and unaffected frequency ranges, creating a shelving response. Implemented using a difference equation with feedback and feedforward coefficients, it provides precise control over the gain, cutoff frequency, and slope of the shelf, making it useful for tonal adjustments in audio processing.

\(f_{0}\) = 1000 Hz

\(Q\) = 0.707

\(Gain\) = 6.0 dB


Formulae:


In order to construct a biquad low shelf filter, the sample rate, cutoff frequency, Q-factor, and Gain (dB) need to be provided. From those, the coefficients for the underlying filter can be calculated:

First, some intermediate values are calculated:

  • \(ω_{0} = 2π{f_{0} \over F_{s}}\)
  • \(α = {sin(ω_{0}) \over {2Q}}\)
  • \(A = 10 ^ {{gain_{dB}} \over 40}\)

Where \(f_{0}\) is the cutoff frequency, \(F_{s}\) is the sample rate, and \(Q\) is the Q-factor.

Then, the filter coefficients can be calculated:

  • \(b_{0} = A((A + 1) - (A - 1)cos(ω_{0}) + 2\sqrt{A}α)\)
  • \(b_{1} = 2A((A - 1) - (A + 1)cos(ω_{0}))\)
  • \(b_{2} = A((A + 1) - (A - 1)cos(ω_{0}) - 2\sqrt{A}α)\)
  • \(a_{0} = (A + 1) + (A - 1)cos(ω_{0}) + 2\sqrt{A}α\)
  • \(a_{1} = -2((A - 1) + (A + 1)cos(ω_{0})\)
  • \(a_{2} = (A + 1) + (A - 1)cos(ω_{0}) - 2\sqrt{A}α\)

Implementation


You can find a C++ and Rust implementation of this and other biquad filters on my GitHub page:

Repo card

Notes:


Since Q-factor is a unit-less value and is a little hard to quantify, sometimes it is easier to provide bandwidth instead. Bandwidth can be converted to the Q-factor by using the formula:

\(Q = {1 \over {2sinh(BW ⋅ {log_{10}(2) \over 2})}}\)