Skip to main content

harmonic_mag_error_db

Function harmonic_mag_error_db 

Source
pub fn harmonic_mag_error_db(
    wdf: &[f64],
    reference: &[f64],
    fundamental_hz: f64,
    sample_rate: f64,
    n_harmonics: usize,
) -> f64
Expand description

Compute the maximum harmonic magnitude error between WDF and reference in dB.

For each harmonic h in 2..=n_harmonics, reads both spectra at the h-th harmonic bin and computes |20*log10(wdf_h) - 20*log10(ref_h)|. Returns the MAX error over harmonics where both bins exceed the −100 dBFS absolute floor (same gate as spectral_error_db).

This is a targeted complement to spectral_error_db: it scores only the discrete harmonic bins, making it meaningful at high-drive levels and immune to broadband noise grass between harmonics.