fn retime_audio(
full: &[f32],
segments: &[TimelineSegment],
source_fps: u32,
sample_rate: u32,
channels: usize,
) -> Vec<f32>Expand description
Retime the source audio to the edited timeline (ED.21).
full is the source’s interleaved F32LE audio (channels samples per
sample-frame). For each timeline segment, the source sample-frame range
[source_start, source_end) — mapped from source video frames via
source_fps and sample_rate — is resampled to the segment’s project
duration: a timescale of 2.0 emits half as many sample-frames (sped
up), 0.5 twice as many (slowed). Linear interpolation between adjacent
sample-frames keeps it click-free; the segments are then concatenated, so
the result matches the retimed video frame-for-frame.
v1 ships speed-with-pitch by design: a sped-up segment rises in pitch,
a slowed one drops — the industry default for editor speed ramps (Premiere
/ FCP / Resolve / Loom all default to it). Pitch-preserving retime
(time-stretch) is a tracked enhancement, ISS-18: it slots in behind
this exact pure (samples, segments, fps, rate, channels) -> Vec<f32>
contract, so callers and tests don’t change when it lands. Pure — no gst,
exhaustively testable.