pub fn bpm_histogram(
beat_frames: &[u32],
frame_rate_hz: f32,
bpm_min: f32,
bpm_max: f32,
out_hist: &mut [u32],
) -> Result<(f32, f32), AudioError>Expand description
Build a BPM histogram from beat frame indices and report the dominant and secondary tempi.
Each adjacent beat pair contributes one inter-beat interval d = beat[i+1] - beat[i] frames, an instantaneous tempo bpm = frame_rate_hz*60/d. Tempi
inside [bpm_min, bpm_max] are binned into out_hist (linearly, out_hist
spanning the whole range). The dominant tempo is the most-populated bin;
the secondary tempo is the most-populated bin at least MIN_PEAK_SEP
bins away from the dominant (a distinct mode, e.g. a half/double-time
alias), or 0.0 if there is no such bin. Both are returned as bin-centre
BPMs.
Returns (dominant_bpm, secondary_bpm).
ยงErrors
AudioError::InvalidParameterif fewer than two beats,out_histis empty,frame_rate_hz <= 0, either bound is non-positive, orbpm_max <= bpm_min.