Skip to main content

max_magnitude_frequency

Function max_magnitude_frequency 

Source
pub fn max_magnitude_frequency(mag: &[f32], sample_rate: f32) -> f32
Expand description

Frequency in Hz of the strongest bin in a one-sided magnitude spectrum mag (DC..Nyquist inclusive; bin spacing sample_rate / (2*(N-1))).

The peak bin is refined with a parabolic fit against its two neighbours when it is interior, giving a sub-bin frequency estimate. Returns 0.0 for an empty spectrum, a non-positive/non-finite sample_rate, or a peak that sits on the DC / Nyquist boundary (no interpolation possible — the bin-centre frequency is returned in that case).