Phase History Swap — User Guide
A phase vocoder effect that hybridizes time: it applies the "texture" (magnitude) of one part of a sound onto the "timing" (phase) of another part.
What this does
This script splits a sound into two temporal sections ("Early" and "Late") and performs a spectral transplantation:
- It takes the Phase (timing/alignment info) from the Early section.
- It takes the Magnitude (volume/timbre info) from the Late section.
- It combines them to synthesize a new sound.
The result is often a "frozen" or "smeared" version of the sound. The tail of the sound tries to exist within the time-structure of the attack. Additionally, by using slightly different split points for Left and Right channels, it generates a unique, wide stereo image from mono sources.
Quick start
- Select a Sound object in Praat.
- Run script… →
Phase History Swap.praat. - Select a Preset:
Subtle Swap: Good starting point to hear the effect.Ghost Echo: Creates a very quiet, distant texture.Wide Stereo: Maximizes the spatial difference between L/R.
- Click OK.
Theory: Magnitude vs. Phase
The DNA of Sound
When we convert sound to the frequency domain (via FFT), we get complex numbers composed of two parts:
- Magnitude (Amplitude): "How loud is this frequency?" This defines the Timbre.
- Phase (Angle): "When does this frequency occur?" This defines the Structure/Transients.
The Swap Logic:
- Normal Time Stretching: Change phase to stretch time, keep magnitude.
- Phase History Swap: Keep phase (Time is locked), Change magnitude (Timbre is replaced).
By forcing the "Late" magnitude (which might be a smooth decay) into the "Early" phase (which aligns to form a sharp transient), we create a paradox: the energy wants to align into a click (phase), but the spectrum describes a smooth wash (magnitude). The result is a "smeary" transient.
Parameters & Presets
Core Controls
| Parameter | Default | Description |
|---|---|---|
| split_at_percent | 50% | The dividing line. Audio before this is "Phase Source". Audio after is "Magnitude Source". |
| stereo_offset_percent | 1.0% | Difference between Left and Right split points. Creates stereo width. |
| crossfade_dur | 0.01s | Smooths the transition point to prevent clicks. |
| fft_win_size | 2048 | Size of analysis window. Larger = better bass resolution, smearier time. |
Preset Guide
- Ghost Echo: Uses a very early split (10%). Takes phase from the very first transient, but magnitude from the long tail. Result: A whisper of the original rhythm.
- Time Smear: Uses a late split (90%). The phase history is long, effectively freezing the texture of the very end of the file.
- Wide Stereo: Sets `split_at_percent=50` and increases `stereo_offset`. Left ear hears the swap based on 50%, Right ear based on 55%. This phase decorrelation sounds "outside the speakers."
Mathematical Deep Dive
1. Complex Reconstruction
The script manipulates the spectral matrix directly using complex number trigonometry. For every frequency bin $k$ and time frame $t$:
Why `arctan2`?
Standard `arctan` only returns angles between -90° and 90°. `arctan2` considers the signs of both Real and Imaginary parts to return the correct phase angle over the full 360° circle (-$\pi$ to $\pi$). This is critical for preserving the position of sound in time.
2. The Time Warp (Column Mapping)
Since the "Early" and "Late" sections might be different lengths (e.g., if split at 30%), the script performs a linear time mapping:
This stretches or compresses the "Late" magnitude matrix to fit exactly onto the dimensions of the "Early" phase matrix, ensuring they line up for the multiplication operation.
Applications
Atmospheric Sound Design
Goal: Turn a piano chord into an ambient drone.
Method: Use Late Swap. The script takes the complex harmonic decay of the piano (Magnitude) and forces it into the sharp attack phase structure. Because the decay lacks the energy in the high frequencies to support a sharp attack, the attack is softened, resulting in a "blooming" or "swelling" texture.
Stereo Widening (Mono to Stereo)
Goal: Make a mono field recording feel immersive.
Method: Use Wide Stereo preset. The script generates two channels. Because the phase information is swapped from slightly different points in time for Left vs Right, the phase correlation decreases. The brain interprets this lack of correlation as spatial width.
Vocoder-like Textures
Goal: "Robotizing" speech without an external carrier.
Method: Use Extreme Late on a spoken sentence. It takes the "noise profile" of the silence/breath at the end of the file and imposes it onto the speech rhythm. The result sounds like the speech is being whispered through a noisy radio.