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.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 0.2 (2025) License: MIT License Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

What this does

This script splits a sound into two temporal sections ("Early" and "Late") and performs a spectral transplantation:

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.

The "Ghost" Effect: Because the phase information dictates when energy happens, keeping the "Early" phase preserves the rhythm of the attack. However, because the magnitude comes from the "Late" tail (which is usually quieter and smoother), the result sounds like a shadow of the original sound—retaining the rhythm but losing the impact.

Quick start

  1. Select a Sound object in Praat.
  2. Run script…Phase History Swap.praat.
  3. 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.
  4. Click OK.
Note: The output will often be quieter than the original because the "Late" section (decay) naturally has less energy than the "Early" section (attack). You may need to normalize the result.

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:

  1. Magnitude (Amplitude): "How loud is this frequency?" This defines the Timbre.
  2. Phase (Angle): "When does this frequency occur?" This defines the Structure/Transients.

The Swap Logic:

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

ParameterDefaultDescription
split_at_percent50%The dividing line. Audio before this is "Phase Source". Audio after is "Magnitude Source".
stereo_offset_percent1.0%Difference between Left and Right split points. Creates stereo width.
crossfade_dur0.01sSmooths the transition point to prevent clicks.
fft_win_size2048Size of analysis window. Larger = better bass resolution, smearier time.

Preset Guide

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$:

Inputs: Real_Early, Imag_Early (from first half) Real_Late, Imag_Late (from second half) Step 1: Extract Components Phase_Target = arctan2(Imag_Early, Real_Early) Mag_Source = sqrt(Real_Late^2 + Imag_Late^2) Step 2: Synthesize Hybrid New_Real = Mag_Source * cos(Phase_Target) New_Imag = Mag_Source * sin(Phase_Target)

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:

Column_Map = round( Current_Col * (Len_Early / Len_Late) )

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.