pub fn estimate_tuning(
peak_freqs: &[f32],
peak_mags: &[f32],
n_peaks: usize,
nominal_ref_hz: f32,
) -> Result<TuningEstimate, AudioError>Expand description
Estimate the reference tuning frequency from spectral peaks.
peak_freqs/peak_mags: parallel peak arrays (Hz, magnitude).n_peaks: leading entries to use (clamped to the shorter array).nominal_ref_hz: the anchor grid frequency to measure against (e.g. 440); parameterised — the estimate is not forced to it.
Deviations are folded into one semitone (100 cents) and averaged on the circle, so octave / semitone offsets of a peak do not bias the result — only its fractional detuning does.
§Errors
AudioError::InvalidParameterifnominal_ref_hzis not positive-finite.