Audacity Time Stretch Algorithm Explained
Audacity uses several specialized digital signal processing algorithms to stretch audio duration while maintaining its original pitch. Depending on the version and the specific tool used, Audacity relies primarily on the SoundTouch library (powered by WSOLA), the high-quality SBSMS engine, and the modern Rubber Band Library for real-time clip stretching. This article outlines these primary algorithms, explaining how they manipulate time domains and frequency spectra to adjust tempo independently of pitch.
1. SoundTouch and the WSOLA Algorithm
The traditional "Change Tempo" effect in Audacity is powered by the open-source SoundTouch audio processing library. SoundTouch primarily uses the WSOLA (Waveform Similarity Overlap-Add) algorithm.
In standard playback, speeding up audio raises its pitch (the "chipmunk effect"), while slowing it down lowers the pitch. WSOLA avoids this by operating in the time domain:
- It divides the incoming audio into short, overlapping frames.
- It analyzes neighboring waveforms to find points of highest cross-correlation (similarity).
- It overlaps and blends these frames (overlap-add) at points of optimal waveform alignment.
By duplicating segments to slow down audio or dropping segments to speed it up—while always aligning waveforms at similar phases—WSOLA maintains the fundamental frequency (pitch) of the source material. This method is computationally lightweight and works well for moderate tempo adjustments (roughly ±15% to 20%), though it can introduce subtle stuttering or fluttering artifacts on complex polyphonic mixes.
2. SBSMS (Subband Sinusoidal Modeling Synthesis)
For higher-fidelity, artifact-free processing, Audacity includes an optional high-quality mode powered by SBSMS (Subband Sinusoidal Modeling Synthesis). This algorithm is accessible in the "Change Tempo," "Change Pitch," and "Sliding Stretch" effects.
SBSMS uses a frequency-domain approach rather than purely slicing time-domain waveforms:
- The audio is separated into multiple frequency subbands using multi-resolution filter banks.
- The algorithm tracks individual sinusoidal frequency components (partials) and residual noise over time.
- It resynthesizes these components over an altered time frame while preserving the precise frequency values of the original sinusoids.
SBSMS preserves transients (such as drum hits) and the natural resonance of acoustic instruments far better than WSOLA. However, it requires significantly more processing time and computing power.
3. Rubber Band Library (Real-Time Clip Stretching)
In recent versions (starting with Audacity 3.5), Audacity introduced real-time, non-destructive clip stretching. This feature is powered by the Rubber Band Library, an industry-standard engine developed by Breakfast Quay.
The Rubber Band algorithm combines phase vocoder technology with time-domain analysis:
- It uses phase vocoder principles to transform audio into the frequency domain via the Fast Fourier Transform (FFT).
- It dynamically tracks transient attack points (percussive sounds) to preserve sharpness.
- It adjusts phase coherence across frequency bins to prevent the "hollow" or "phasiness" sound common in older phase vocoders.
Rubber Band allows users to hold the Alt (or Option) key and drag the edge of an audio clip directly in the timeline to stretch or compress it instantaneously, without pre-rendering or altering the pitch.
4. Paulstretch (Extreme Stretching)
For non-traditional, extreme time manipulation, Audacity also includes Paulstretch (developed by Paul Nasca). When stretching audio by extreme factors (such as 10x to 100x):
- Paulstretch analyzes the audio in very large FFT frequency windows.
- It randomizes the phase of the frequencies while maintaining their amplitude.
- It synthesizes the result into a smooth, ambient texture.
While not meant for natural tempo corrections, Paulstretch allows infinite pitch-preserved time-stretching without rhythmic stutter.