Skip to main content

salient_pitch_peaks

Function salient_pitch_peaks 

Source
pub fn salient_pitch_peaks(
    salience: &[f32],
    n_bins: usize,
    threshold_ratio: f32,
    min_distance_bins: usize,
    out_bins: &mut [f32],
    out_salience: &mut [f32],
) -> Result<usize, AudioError>
Expand description

Pick the salient pitch candidates (salience-curve peaks) of one frame.

A candidate is a local maximum of salience[0..n_bins] whose value is at least threshold_ratio * max(salience); candidates closer than min_distance_bins bins are resolved in favour of the stronger (via the reused peak picker). Output is written bin-ascending: out_bins[k] the sub-bin candidate position and out_salience[k] its salience.

Returns the number of candidates written.

  • salience: the frame’s salience curve; only [0, n_bins) is read.
  • threshold_ratio: relative floor in [0, 1] (e.g. 0.1).
  • min_distance_bins: minimum spacing between accepted candidates.

§Errors