Ohmic Audio

⚙️ ENGINEER LEVEL: IIR and FIR Implementation

Biquad IIR Filter Mathematics

Every parametric EQ band, crossover section, and shelf filter in a DSP is typically a biquad (second-order) IIR section.

Transfer function:

H(z) = (b₀ + b₁z⁻¹ + b₂z⁻²) / (1 + a₁z⁻¹ + a₂z⁻²)

Difference equation:

y[n] = b₀x[n] + b₁x[n-1] + b₂x[n-2] − a₁y[n-1] − a₂y[n-2]

Butterworth HPF coefficients (from bilinear transform):

ω₀ = 2πf_c / f_s
α = sin(ω₀) / (2Q)

b₀ = (1 + cos(ω₀)) / 2
b₁ = −(1 + cos(ω₀))
b₂ = (1 + cos(ω₀)) / 2
a₀ = 1 + α
a₁ = −2cos(ω₀)
a₂ = 1 − α

Normalize all by a₀.

Parametric peaking EQ coefficients:

A = 10^(gain_dB / 40)
ω₀ = 2πf_c / f_s
α = sin(ω₀) / (2Q)

b₀ = 1 + α×A
b₁ = −2cos(ω₀)
b₂ = 1 − α×A
a₀ = 1 + α/A
a₁ = −2cos(ω₀)
a₂ = 1 − α/A

Normalize all by a₀.

SOS cascade:

Higher-order filters use cascaded biquad sections. A 4th-order Linkwitz-Riley is implemented as two cascaded identical 2nd-order Butterworth sections.

Coefficient quantization:

In 24-bit fixed-point DSPs, coefficients have ~7 significant decimal places. Filters with very low cutoff frequencies (relative to sample rate) or very high Q develop coefficients near ±1 — precision is lost and the filter may behave incorrectly.

Solution: Increase sample rate or use double-precision arithmetic for coefficient computation.

FIR Filter Design Workflow

For linear-phase crossovers and room correction curves, FIR filters are required.

Design parameters:

Minimum filter length:

N ≈ (f_s × D_att) / (22 × BW_transition)

Where Datt = desired stopband attenuation in dB, BWtransition in Hz.

Example: 48 kHz system, need 60 dB attenuation with 500 Hz transition at an 80 Hz crossover:

N ≈ (48000 × 60) / (22 × 500) = 261 taps

Parks-McClellan (optimal equiripple) design:

MATLAB: h = firpm(N, [f1 f2 f3 f4], [A1 A2], W)

This produces the shortest filter meeting specs, with equal ripple in passband and stopband.

Linear-phase latency:

FIR filters introduce latency equal to half the filter length:

Latency = N / (2 × f_s)

For 261-tap filter at 48 kHz:

Latency = 261 / (2 × 48000) = 2.7 ms

All channels must have the same (or compensated) latency to maintain alignment.

Mixed-mode processing:

Most commercial car audio DSPs use: - IIR for crossovers and EQ (low CPU, low latency) - FIR for room correction curves (linear phase, higher CPU)

Some premium DSPs (Helix DSP Pro, miniDSP C-DSP) allow user-uploaded FIR coefficients via text file — enabling Dirac Live, REW convolution correction, or custom-designed filters.


4.6 Sound Quality vs SPL Competition