pub fn make_loop_buffer(
samples: &[f32],
sr: u32,
start_secs: f32,
end_secs: Option<f32>,
crossfade_secs: f32,
) -> Vec<f32>Expand description
Extract the loop region [start_secs, end_secs) and equal-power crossfade
its last crossfade_secs onto its head, returning a buffer that repeats
seamlessly. The output length is the region minus the crossfade.
Overlap-loop: with region r of length L and crossfade x, the body is
r[0..L-x] with its first x samples replaced by a sin/cos blend of the
head (r[i], fading in) and the tail (r[L-x+i], fading out). The wrap
out[last] → out[0] then lands on adjacent original samples, so there is no
discontinuity.