Skip to main content

multipitch_klapuri

Function multipitch_klapuri 

Source
pub fn multipitch_klapuri(
    mag: &[f32],
    sample_rate: f32,
    f_min: f32,
    f_max: f32,
    max_polyphony: usize,
    salience_threshold: f32,
    out_f0: &mut [f32],
    scratch: &mut [f32],
) -> Result<usize, AudioError>
Expand description

Iterative spectral-subtraction multi-pitch estimation.

  • mag: one-sided magnitude spectrum covering DC..Nyquist inclusive (length N/2+1 for an FFT of size 2*(mag.len()-1)), e.g. from crate::features::fft::real_fft_magnitude. Not modified.
  • sample_rate: Hz; sets the bin spacing sample_rate / (2*(mag.len()-1)).
  • f_min / f_max: inclusive fundamental-frequency search range in Hz.
  • max_polyphony: the declared maximum number of concurrent pitches to propose (the estimator writes at most min(max_polyphony, out_f0.len())).
  • salience_threshold: absolute salience floor; the loop stops (abstains) as soon as the residual’s strongest salience is below it.
  • out_f0: caller buffer; detected fundamentals are written salience order (strongest first).
  • scratch: caller buffer of length >= mag.len() + salience_bins(f_min, f_max); used as the residual magnitude copy followed by the salience curve.

Returns the number of F0s written.

§Errors