pub fn segment_boundaries(
novelty: &[f32],
n_frames: usize,
threshold: f32,
min_distance: usize,
pos_scratch: &mut [f32],
mag_scratch: &mut [f32],
out_boundaries: &mut [usize],
) -> Result<usize, AudioError>Expand description
Propose segment boundaries as novelty-curve peak frame indices.
novelty is a per-frame novelty curve (as produced by
super::novelty::novelty_curve); only its first n_frames values are
examined. A frame is a boundary candidate when the novelty curve has a local
maximum there of at least threshold, with peaks closer than min_distance
frames resolved in favour of the taller one (see detect_peaks). Ascending
boundary frame indices are written to out_boundaries; the count is
returned.
§Caller-buffer contract (zero-heap)
pos_scratch and mag_scratch are caller-owned working buffers handed
straight to detect_peaks (each must hold at least as many entries as the
number of peaks you expect to accept). The rounded frame indices are then
written into out_boundaries. No heap allocation is performed.
§Errors
AudioError::InvalidParameterifn_frames == 0,n_framesexceedsnovelty.len(), orthresholdis not finite.AudioError::OutputBufferTooSmallifout_boundariescannot hold every accepted peak (propagated fromdetect_peaksfor the scratch buffers).