Expand description
Klapuri-style iterative spectral-subtraction multi-pitch estimation.
Repeatedly (1) find the most salient fundamental in the residual magnitude
spectrum, (2) estimate + cancel its harmonic series, and (3) recurse on the
residual — up to max_polyphony sources or until the strongest remaining
salience falls below salience_threshold. This is the classic Klapuri
predominant-F0 cancellation loop (Klapuri, “Multiple fundamental frequency
estimation by summing harmonic amplitudes”, ISMIR 2006).
REUSE: the per-iteration salience is built from the shared primitives — the
residual’s spectral peaks come from
crate::features::peaks::spectral_peaks() and are folded into a harmonic
pitch-salience curve by crate::features::salience::pitch_salience. This
module adds only the iteration + cancellation on top of those.
EPISTEMIC RULE (declared): the returned F0s are proposals, not ground
truth. The max-polyphony assumption is explicit — the caller states, via
max_polyphony, the largest number of concurrent pitches it is willing to
posit; the estimator never invents more than that, and it abstains
(stops early, possibly at zero) as soon as the residual’s best salience drops
below salience_threshold. A single-tone spectrum therefore yields exactly
one F0 and a flat/noise spectrum yields none.
Zero-heap hot path: the only working buffer is the caller-owned scratch,
which holds the residual magnitude copy followed by the salience curve; the
bounded spectral-peak lists live in fixed stack arrays.
Functions§
- multipitch_
klapuri - Iterative spectral-subtraction multi-pitch estimation.