Audio Time-Stretching vs. Pitch Shifting: Browser OLA & Semitone Math Explained

By Asif Nawaz · Published November 25, 2026 · Web Audio DSP Handbook · 6 min read

If you have ever sped up a cassette tape or nudged a vinyl turntable faster, you know that speed and musical pitch are physically coupled in analog playback: playing a 440 Hz tuning note twice as fast compresses its wavelength in half, jumping instantaneously to 880 Hz (one full octave higher). Digital audio gives engineers the power to break that physical link—allowing musicians to slow down an intricate solo to 0.60× while staying perfectly in tune, or letting singers drop a backing track by three semitones without altering tempo.

1. How Hann-Windowed Overlap-Add (OLA) Decouples Tempo From Pitch

To change an audio file's duration without changing its pitch inside a web browser, digital signal processing splits the decoded Float32Array waveform into short, smooth frames (typically 40ms to 45ms, or roughly 1,850 samples at 44.1 kHz). Each frame is multiplied by a bell-shaped Hann window that tapers gently to zero at both edges so consecutive slices never create audible clicks.

75% Overlapping Hann Windows (OLA) + Optional Pitch Resampling Step 1: OLA Time-Stretch (anaHop = synHop × factor) Changes duration cleanly without shifting frequency Step 2: Pitch Ratio r = 2^(semitones / 12) Linear interpolation shifts key without altering tempo 16-Bit PCM WAV RIFF + fmt + data 0 Server Uploads

Figure 1: Combining compensatory OLA time-stretching with 12-TET pitch resampling delivers independent speed and musical key control in pure JavaScript.

By reading frames from the input at an analysis hop (anaHop = synHop × stretchFactor) while placing them into the output buffer at a fixed synthesis hop (25% of window length = 75% overlap), the overlapping Hann windows sum to a constant amplitude envelope. Dividing by the accumulated window weight eliminates volume ripple completely.

2. Twelve-Tone Equal Temperament (12-TET) Semitone Math

Western musical scales divide every octave (a 2:1 frequency doubling) into twelve logarithmic steps called semitones. To transpose an audio track by n semitones, the exact pitch ratio is:

pitchRatio = 2 ^ (n / 12)

Semitone Shift Exact Pitch Ratio Musical Interval (From Key of C) Typical Practical Use
−12 st 0.5000× 1 Octave Down (C) Deep bass octave transposition
−2 st 0.8909× Whole Step Down (Bb) Making high chorus vocals comfortable to sing
−1 st 0.9439× Half Step Down (B) Matching Eb guitar tuning without retuning strings
+3 st 1.1892× Minor Third Up (Eb) Raising low acoustic backing tracks
+12 st 2.0000× 1 Octave Up (C) Full upper-octave harmonic layer

3. How Independent Speed + Pitch Works Together

Suppose you want a track to play at 1.50× speed and shifted up +3 semitones (pitchRatio = 1.1892). A two-stage pipeline solves this cleanly: first, OLA time-stretches the audio by speed / pitchRatio = 1.50 / 1.1892 = 1.2613; second, linear resampling applies 1.1892. The combined duration change equals 1.2613 × 1.1892 = 1.50× exactly, while the musical pitch shifts by exactly +3.0 semitones.

4. Equal-Power Crossfading & Peak Normalization When Merging Clips

When combining multiple tracks in a browser—such as a podcast intro, spoken interview, and closing outro—a straight linear fade multiplies both overlapping clips by 0.50 at the midpoint. Because uncorrelated audio waves sum in power rather than simple amplitude (0.5² + 0.5² = 0.50), a linear blend creates an audible −3.0 dB loudness dip. Applying a quarter-wave sine/cosine equal-power curve keeps summed acoustic energy constant (cos²θ + sin²θ = 1.0), while scaling the final master peak to −1.0 dBFS prevents 16-bit integer clipping during overlapping choruses. You can test both equal-power crossfading and automatic peak normalization locally in our Audio Joiner & Merger Studio.

5. Why Browser-Local 16-Bit PCM WAV Export Preserves Quality

Re-encoding processed audio into a lossy MP3 discards psychoacoustic detail a second time and adds encoder padding silence at the beginning of each file. Writing a standard 44-byte RIFF/WAVE header (RIFF, WAVE, fmt , and data chunks) followed by interleaved signed 16-bit little-endian PCM samples directly from browser Float32Array memory preserves every sample accurately, runs in milliseconds without server queues, and works offline on desktop and mobile devices.

Try Real-Time Audio Speed, Pitch & Multi-Track Joining Locally

Drop any MP3, WAV, M4A, or FLAC file—or test our built-in studio demos with A/B looping, equal-power crossfades, and instant WAV export.

Open Speed & Pitch → Open Audio Joiner →