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 (lengthN/2+1for an FFT of size2*(mag.len()-1)), e.g. fromcrate::features::fft::real_fft_magnitude. Not modified.sample_rate: Hz; sets the bin spacingsample_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 mostmin(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
AudioError::InvalidParameterifsample_rate,f_min,f_maxare not positive finite withf_max > f_min,salience_thresholdis negative or non-finite, ormag.len() < 3.AudioError::OutputBufferTooSmallifscratchcannot hold the residual plus the salience curve.