Skip to main content

track_contours

Function track_contours 

Source
pub fn track_contours(
    peak_bins: &[f32],
    peak_count: &[usize],
    n_frames: usize,
    max_peaks_per_frame: usize,
    pitch_tol_bins: f32,
    out_contour_id: &mut [i32],
) -> Result<usize, AudioError>
Expand description

Link per-frame salience peaks into time-continuous pitch contours.

peak_bins is a flat row-major buffer of shape n_frames × max_peaks_per_frame (peak_bins[f * max_peaks_per_frame + k]), holding the bin position of the k-th candidate in frame f; peak_count[f] gives how many of that frame’s max_peaks_per_frame slots are valid (candidates occupy slots 0..count).

Writes one contour id per candidate slot into out_contour_id (same layout as peak_bins): candidates sharing an id form one contour; unused slots are set to NO_CONTOUR (-1). Two candidates in consecutive frames whose bins differ by at most pitch_tol_bins may join the same contour.

Returns the number of distinct contours created.

§Errors