Skip to main content

Time-Stretch & Speed

Pitch-preserving time-stretch is libavfilter's rubberband filter, wrapped by vv_audio::stretch_samples. No extra bindings are needed: the system FFmpeg is built with librubberband. Stretching is used in two places.

Clip speed

pitch_correctionHow the clip's audio is read
true (default)The clip's range is stretched by its speed with stretch_range, then played at step 1. In preview a background worker in mix_buffers.rs does the stretching; until it is ready the clip counts as pending. Export stretches synchronously.
falseVarispeed: pitch follows speed. Slowing down uses linear interpolation; speeding up averages the skipped frames as a crude low-pass against aliasing.

Fast-forward playback (2x / 4x / 8x)

Stretching a whole track would delay the first sound by seconds, so the preview stretches the mix in windows.

audio-fast-forward.png
RuleWhy
Windows of 8 s of timeline audioOne window comes back in ~150–200 ms. 8 s is a multiple of every tempo, so queued windows do not drift.
Next window when less than 4 s is left unplayedAt 8x that is 0.5 s of real time, more than the stretch takes.
At most one request in flight; stale results droppedA seek or speed change while stretching must not play old audio.
1x applies at once; 2x/4x/8x when the first window is readyThe stream is never reopened. The callback switches to render_stretched, which advances the position by frames × tempo.