Skip to main content

thd_plus_n_db

Function thd_plus_n_db 

Source
pub fn thd_plus_n_db(
    signal: &[f64],
    fundamental_hz: f64,
    sample_rate: f64,
) -> f64
Expand description

Compute THD+N (Total Harmonic Distortion plus Noise) in dB.

THD+N = 10 * log10((total_power - fundamental_power) / fundamental_power)

Unlike thd_db, which sums only discrete harmonic bins, THD+N includes broadband noise and intermodulation products across ALL bins except the fundamental. Uses Blackman window for spectral analysis.

The fundamental exclusion zone is ±3 bins to prevent Blackman window sidelobes from artificially inflating the noise estimate.