Skip to main content

Module filter_analysis

Module filter_analysis 

Source
Expand description

Frequency-response, group-delay, and pole-based stability analysis for filters produced by crate::filter_design or hand-written FIR/biquad coefficients.

These routines evaluate the DTFT H(e^{jω}) of a coefficient set directly (no FFT required), so a filter design can be inspected at arbitrary frequencies before it is deployed to a real-time processing path.

Functions§

biquad_cascade_frequency_response
Evaluates the combined frequency response of a cascade of Direct Form I biquad sections (coeffs.len() must be a multiple of 5, as produced by e.g. crate::filter_design::butterworth_lowpass_biquads) at a single normalized frequency freq_norm (cycles/sample, 0.0..=0.5).
biquad_cascade_is_stable
Returns true if every stage of a biquad cascade (coeffs.len() a multiple of 5) is stable.
biquad_frequency_response
Evaluates the frequency response H(e^{jω}) of a single Direct Form I biquad section [b0, b1, b2, a1, a2] (as produced by crate::filter_design and consumed by crate::filtering::biquad_cascade_df1_f32, where `y(n) = b0 x(n) + b1 x(n-1) + b2 x(n-2)
biquad_is_stable
Returns true if the single biquad section [b0, b1, b2, a1, a2] is stable, i.e. both poles lie strictly inside the unit circle.
biquad_l2_norm
Computes the L2-norm energy ||H(e^{jω})||_2 of a biquad section.
biquad_peak_gain
Computes the peak frequency response gain ||H(e^{jω})||_∞ of a biquad section.
biquad_pole_radius
Computes the pole radius (largest pole magnitude on the z-plane) of a single Direct Form I biquad section [b0, b1, b2, a1, a2], whose poles are the roots of z^2 - a1*z - a2 = 0. A causal LTI system is stable if and only if all poles lie strictly inside the unit circle (pole_radius < 1.0).
biquad_q15_frequency_response
Evaluates the frequency response of a Q15 quantized biquad section.
biquad_quantization_snr_db
Computes the Signal-to-Quantization-Noise Ratio (SQNR in dB) between an ideal floating-point biquad cascade and its Q15 quantized equivalent.
estimate_biquad_headroom_bits
Estimates required integer headroom bits and peak gain for a biquad section.
fir_frequency_response
Evaluates the frequency response H(e^{jω}) = Σ h[k] e^{-jkω} of an FIR filter (or any raw coefficient sequence) at a single normalized frequency freq_norm (cycles/sample, 0.0..=0.5, where 0.5 is Nyquist).
fir_group_delay
Computes the group delay (in samples), τ(ω) = Re[B(e^{jω}) / H(e^{jω})] where B(e^{jω}) = Σ k·h[k]·e^{-jkω}, of an FIR filter at a single normalized frequency freq_norm (cycles/sample, 0.0..=0.5). For a linear-phase (symmetric) FIR of length M, this is constant and equal to (M - 1) / 2 at every frequency.
fir_quantization_snr_db
Computes the SQNR (in dB) between an ideal floating-point FIR filter and its Q15 quantized version.
response_magnitude
Returns the linear magnitude |H(e^{jω})| of a complex frequency-response value.
response_magnitude_db
Returns the magnitude of a complex frequency-response value in decibels: 20 * log10(|H|).
response_phase
Returns the phase (argument) of a complex frequency-response value, in radians, wrapped to (-π, π].