Skip to main content

segment_contour

Function segment_contour 

Source
pub fn segment_contour(
    contour_bins: &[f32],
    n_points: usize,
    stable_tol_bins: f32,
    min_note_frames: usize,
    out_start: &mut [usize],
    out_len: &mut [usize],
    out_pitch: &mut [f32],
) -> Result<usize, AudioError>
Expand description

Segment contour_bins[0..n_points] into stable-pitch note events.

contour_bins[i] is the pitch of frame i on the salience grid (any monotonic pitch scale in units where stable_tol_bins is meaningful); a value of 0.0 marks an unvoiced frame that cannot belong to a note. A note is a run whose every frame lies within stable_tol_bins of the run’s running mean; the run closes when a frame breaks that bound or is unvoiced. Runs of at least min_note_frames frames are emitted:

  • out_start[k]: first frame index of note k.
  • out_len[k]: number of frames in note k.
  • out_pitch[k]: mean pitch (bins) over note k.

Returns the number of notes written.

§Errors