← Gallery Live speed control — playbackRate vs resample

Live speed control — playbackRate vs resample

scripts/live-speed-control.js

Doubling a track's speed live can go two ways: the turntable way, where everything jumps up an octave, or the pitch-preserving way, where the groove speeds up but stays at the same pitch. This page plays both, and each tier leaves an assertable signature proving which path ran. playbackRate tier: applyLiveDoubleSpeed() crossfades to a replacement source whose playbackRate.value must be exactly 2.0, stopping the old source after the 50 ms fade (the audible octave jump). Resample tier (preservePitch: true): the returned buffer keeps the ORIGINAL length, newLoopLength === floor(len/2), and the trailing half must be exactly silent — 2× resampling writes the compressed audio into the first half only; that silence is the tier's assertable signature. resetLiveSpeed() restores rate 1.0. Dependencies are injected explicitly (no window bus). Resample + error contract asserts spot-run headless in Node pre-ship.

loading golden WAV…