Frequency-Dependent Phase Manipulation — User Guide

Spectral phase processing: applies frequency-dependent phase shifts to create stereo width, texture, and spectral effects through phase manipulation in the frequency domain.

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

What this does

This script implements frequency-dependent phase manipulation — a spectral processing technique that applies different phase shift functions to left and right channels to create stereo width and spectral effects. Process converts sound to frequency domain, manipulates phase component while preserving magnitude, then converts back to time domain with modified phase relationships. Four phase manipulation modes available: (1) Comb filter: Periodic notches via sinusoidal phase modulation. (2) Chaotic texture: Multiple periodic functions for complex phase relationships. (3) Spectral blur: Randomized phase modulation for smearing effects. (4) Formant-like resonances: Gaussian-shaped phase shifts at specific frequency regions.

Key Features:

What is phase manipulation? Traditional audio: amplitude and frequency domains well-understood. Phase domain: often overlooked but critical for perception. Phase relationships between frequencies affect: (1) Timbre: Phase interactions create comb filtering, resonance. (2) Stereo image: Phase differences between ears create spatial perception. (3) Transient preservation: Phase coherence maintains sharp attacks. This script manipulates phase deliberately to create: Stereo widening (different L/R phase), Spectral effects (comb filtering, resonances), Textural changes (phase smearing, blurring). Unlike EQ (magnitude manipulation) or compression (amplitude manipulation), phase processing changes timing relationships between frequency components without altering their amplitudes.

Technical Implementation: (1) Input preparation: Convert to mono if stereo input, ensure single-channel processing foundation. (2) Frequency domain conversion: Convert sound to spectrum (complex FFT representation with real/imaginary components). (3) Matrix representation: Convert spectrum to matrix for mathematical manipulation. (4) Phase manipulation: Apply frequency-dependent phase shift formulas to matrix data. Different formulas for different effects: Comb = periodic sine modulation, Chaos = multiple sine waves, Blur = randomized modulation, Formant = Gaussian peaks. (5) Stereo differentiation: Apply slightly different phase amounts to L/R channels. (6) Reconstruction: Convert modified matrices back to spectra, then to time-domain sounds. (7) Stereo combination: Merge L/R channels into final stereo output. Key insight: Phase = arctan(imaginary/real) in complex spectrum. Manipulating phase while preserving magnitude creates timbral/spatial changes without amplitude alteration.

Quick start

  1. In Praat, select exactly one Sound object (mono or stereo).
  2. Run script…frequency_dependent_phase_manipulation.praat.
  3. Choose Phase_mode: Comb filter, Chaotic texture, Spectral blur, or Formant-like resonances.
  4. Adjust Phase_amount (default 50.0) — higher = more dramatic effect.
  5. Set Stereo_width (default 0.2) — difference between L/R phase processing.
  6. Click OK — phase manipulation applied, stereo result named "originalname_StereoPhase_mode_amount".
  7. Output automatically played for immediate evaluation.
Quick tip: Start with Comb filter mode for classic phaser/flanger effects. Use Chaotic texture for complex, evolving phase relationships. Try Spectral blur for smeared, washy textures. Use Formant-like resonances for vowel-like spectral emphasis. Moderate Phase_amount (30-70) for subtle effects, high values (100+) for dramatic transformation. Small Stereo_width (0.1-0.3) for natural stereo, larger values (0.5-1.0) for extreme width. Processing time depends on sound length and complexity. Output is stereo regardless of input. Original sound preserved in Objects window.
Important: PHASE EFFECTS ARE SUBTLE — may be less audible on mono systems or with certain program material. Extreme Phase_amount can cause phase cancellation when summed to mono. Very high Stereo_width can create unstable stereo image or perception issues. Comb filter mode creates periodic notches that may remove specific frequencies. Spectral blur can reduce transient clarity and definition. Formant mode emphasizes specific frequency regions which may not suit all material. Always check results on both stereo and mono systems. Phase manipulation is non-destructive but the effects are baked into the output file.

Phase Manipulation Theory

Fourier Analysis Basics

Complex Spectrum Representation

Sound in frequency domain:

Time domain: s(t) - amplitude over time Frequency domain: S(f) - complex spectrum S(f) = R(f) + i·I(f) Where: R(f) = real component at frequency f I(f) = imaginary component at frequency f i = √-1 (imaginary unit) Alternative representation: S(f) = M(f) · e^(i·φ(f)) Where: M(f) = magnitude (amplitude) = √[R(f)² + I(f)²] φ(f) = phase = arctan(I(f) / R(f)) This script manipulates φ(f) while preserving M(f)

Why Manipulate Phase?

Phase perception effects:

Traditional vs phase processing:

Phase Shift Mathematics

Basic Phase Rotation

Applying phase shift:

Original complex value: S = R + iI = M·e^(iφ) Phase shift by θ: S' = M·e^(i(φ + θ)) In rectangular coordinates: R' = M·cos(φ + θ) I' = M·sin(φ + θ) But we only have R and I, so: R' = R·cos(θ) - I·sin(θ) I' = R·sin(θ) + I·cos(θ) This is the rotation formula used in the script

Frequency-Dependent Phase

Making phase shift vary with frequency:

Simple phase shift: θ constant for all frequencies Frequency-dependent: θ(f) varies with frequency This script uses: θ(f) = A · F(f) Where: A = Phase_amount (overall strength) F(f) = frequency-dependent function (different for each mode) Examples: Comb: F(f) = sin(2πf/200) Chaos: F(f) = sin(2πf/147) + 0.7·sin(2πf/283) + 0.4·sin(2πf/521) Blur: F(f) = sin(f/37)·sin(f/113) Formant: F(f) = exp(-((f-800)/300)²) + exp(-((f-1500)/400)²) + exp(-((f-2500)/500)²) Different F(f) create different sonic characters

📐 Visual Intuition

Comb filter phase function:

θ(f) = A·sin(2πf/200)

Creates periodic phase shifts → periodic cancellations in spectrum

Notches occur where phase differences cause cancellation

Use: Classic phaser/flanger effects


Formant phase function:

θ(f) = A·[Gaussian(800Hz) + Gaussian(1500Hz) + Gaussian(2500Hz)]

Emphasizes specific frequency regions → vowel-like resonances

Peaks at formant frequencies create spectral emphasis

Use: Vocal-like spectral shaping

Stereo Phase Differences

Creating Stereo Width

Independent L/R phase processing:

Left channel: θ_L(f) = A · F(f) Right channel: θ_R(f) = A · (1 + W) · F(f) Where: A = Phase_amount W = Stereo_width F(f) = frequency-dependent function Example: A=50, W=0.2, Comb mode θ_L(f) = 50 · sin(2πf/200) θ_R(f) = 50 · 1.2 · sin(2πf/200) = 60 · sin(2πf/200) Right channel gets 20% stronger phase modulation → Different phase relationships between ears → Psychoacoustic stereo widening

Why This Creates Stereo

Psychoacoustic principles:

Interaural Phase Differences (IPD):

Natural stereo: Sounds arrive at slightly different times at each ear
→ Phase differences between ears
→ Brain interprets as spatial position

This script: Artificially creates phase differences
Left and right channels get different phase shifts
→ Brain interprets artificial IPD as stereo width
→ Even though source was mono

Result: Mono input → wide stereo output
Width controlled by Stereo_width parameter

Processing Pipeline

Complete Algorithm

Step-by-step processing:

STEP 1: INPUT PREPARATION Select Sound object If stereo → convert to mono (n_channels > 1) mono_sound = Convert to mono STEP 2: FREQUENCY DOMAIN CONVERSION spectrum_L = To Spectrum: "yes" (FFT with complex values) matrix_L = To Matrix (for mathematical manipulation) STEP 3: PHASE MANIPULATION - LEFT CHANNEL Copy matrix_L → matrix_L_shifted Apply phase formula to matrix_L_shifted Example (Comb mode): Formula: "if row=1 then M·cos(φ + A·sin(2πx/200)) else M·sin(φ + A·sin(2πx/200)) fi" Where M = magnitude, φ = original phase STEP 4: PHASE MANIPULATION - RIGHT CHANNEL Same process but with A_R = A·(1 + W) Different phase amount for stereo difference STEP 5: RECONSTRUCTION spectrum_L_mod = To Spectrum (from modified matrix) sound_L = To Sound (inverse FFT) Same for right channel → sound_R STEP 6: STEREO COMBINATION stereo_sound = Combine to stereo (sound_L, sound_R) Normalize peak to 0.99 Rename with parameters Play result OUTPUT: "originalname_StereoPhase_mode_amount"

Matrix Manipulation Details

Why use matrix representation?

Spectrum object: complex values (real + imaginary) Matrix: 2 rows × nColumns frequency bins Row 1: real components Row 2: imaginary components Phase manipulation requires: Magnitude: M = √(real² + imag²) Phase: φ = arctan(imag / real) New phase: φ' = φ + θ(f) New real: real' = M·cos(φ') New imag: imag' = M·sin(φ') Matrix Formula implementation: References original matrix values Computes new real/imag based on phase shift Preserves magnitude, changes phase only Efficient: single formula application to entire matrix

Mathematical Foundation

COMPLEX NUMBERS REVIEW: Complex number: z = x + iy Magnitude: |z| = √(x² + y²) Phase: arg(z) = arctan(y/x) Polar form: z = |z|·e^(i·arg(z)) PHASE SHIFT: Original: z = |z|·e^(iφ) Shifted: z' = |z|·e^(i(φ + θ)) Euler's formula: e^(iθ) = cosθ + i·sinθ Therefore: z' = |z|·[cos(φ+θ) + i·sin(φ+θ)] = |z|·[(cosφ·cosθ - sinφ·sinθ) + i·(sinφ·cosθ + cosφ·sinθ)] = (|z|cosφ)·cosθ - (|z|sinφ)·sinθ + i·[(|z|sinφ)·cosθ + (|z|cosφ)·sinθ] = x·cosθ - y·sinθ + i·[y·cosθ + x·sinθ] Where x = real part, y = imaginary part This matches the rotation formula used in script

Phase Manipulation Modes

Mode 1: Comb Filter

🔁 Periodic Notches

Formula: θ(f) = A · sin(2πf / 200)

Character: Classic phaser/flanger effect, periodic spectral notches

Best for: Adding motion, creating classic modulation effects

Technical details:

AspectDescriptionSonic Result
Periodicity200Hz period in frequency domainEvenly spaced notches every 200Hz
Phase CancellationWhere sin() ≈ 0, minimal effectPreserved frequencies
Phase RotationWhere |sin()| large, strong phase shiftCancellation notches
Stereo VersionDifferent period scaling L/RMoving, swirling notches

Mode 2: Chaotic Texture

🌀 Multiple Periods

Formula: θ(f) = A · [sin(2πf/147) + 0.7·sin(2πf/283) + 0.4·sin(2πf/521)]

Character: Complex, evolving phase relationships, textured sound

Best for: Adding complexity, creating evolving textures

Technical details:

AspectDescriptionSonic Result
Multiple Frequencies147Hz, 283Hz, 521Hz periodsRich, complex notch pattern
Amplitude Scaling1.0, 0.7, 0.4 coefficientsLayered intensity
Irrational Ratios147:283:521 ≈ 1:1.93:3.54Non-repeating pattern
Beat FrequenciesInterference between periodsEvolving, moving texture

Mode 3: Spectral Blur

🌫️ Randomized Modulation

Formula: θ(f) = A · sin(f/37) · sin(f/113)

Character: Smearing, blurring, washy texture

Best for: Creating ambient textures, reducing transient sharpness

Technical details:

AspectDescriptionSonic Result
Product of Sinessin(f/37)·sin(f/113)Complex modulation
Low Frequency Modulation37Hz and 113Hz ratesSlow, evolving changes
MultiplicationCreates sum/difference frequenciesRich spectral content
Transient SmearingPhase incoherence across frequenciesReduced attack sharpness

Mode 4: Formant-Like Resonances

🎵 Gaussian Peaks

Formula: θ(f) = A · [Gaussian(800Hz) + Gaussian(1500Hz) + Gaussian(2500Hz)]

Character: Vowel-like spectral emphasis, resonant peaks

Best for: Vocal-like shaping, frequency region emphasis

Technical details:

AspectDescriptionSonic Result
Gaussian Functionsexp(-((f-center)/width)²)Smooth, bell-shaped curves
Formant Centers800Hz, 1500Hz, 2500HzVowel-like frequency regions
Bandwidths300Hz, 400Hz, 500HzRealistic formant widths
Phase ReinforcementStrong shifts at formant centersSpectral emphasis

Parameters & Effects

Core Parameters

ParameterTypeDefaultDescription
Phase_modeoptionComb filterType of phase manipulation
Phase_amountpositive50.0Strength of phase effect
Stereo_widthpositive0.2L/R phase difference multiplier

Parameter Ranges & Effects

ParameterRangeLow Value EffectHigh Value Effect
Phase_amount10-200Subtle phase coloringDramatic transformation
Stereo_width0.1-1.0Natural stereo imageExtreme width, possible instability

Mode-Specific Characteristics

ModeIdeal Phase_amountIdeal Stereo_widthTypical Use
Comb filter30-800.1-0.3Modulation effects, motion
Chaotic texture40-1000.2-0.4Complex textures, evolution
Spectral blur20-600.1-0.2Ambient textures, smearing
Formant resonances50-1200.3-0.6Vocal shaping, spectral emphasis

Applications

Stereo Enhancement

Use case: Converting mono sources to stereo, widening narrow recordings

Technique: Use moderate Phase_amount (40-60) with Stereo_width 0.2-0.4

Example: Comb filter mode on mono vocal → natural stereo width

Sound Design & Textures

Use case: Creating evolving textures, ambient pads

Technique: Chaotic texture or Spectral blur modes with high Phase_amount

Example: Spectral blur on synth pad → washy, smeared texture

Special Effects

Use case: Phaser/flanger effects, vocal processing

Technique: Comb filter mode with varying Phase_amount

Workflow:

Experimental Composition

Use case: Spectral composition, phase-based structures

Advantages:

Example: Formant mode to create artificial vowel spectra

Mono Compatibility Testing

Use case: Testing stereo mixes for mono compatibility

Technique: Extreme phase manipulation reveals mono issues

Application: Identify phase cancellation problems in mixes

Practical Workflow Examples

🎵 Stereo Vocal Enhancement

Goal: Convert mono vocal to natural stereo

Settings:

  • Mode: Comb filter
  • Phase_amount: 45
  • Stereo_width: 0.25

Result: Natural stereo width without artificial doubling

🎹 Synth Pad Texturing

Goal: Add movement and complexity to static synth pad

Settings:

  • Mode: Chaotic texture
  • Phase_amount: 75
  • Stereo_width: 0.35

Result: Evolving, complex texture with wide stereo image

🥁 Drum Smearing

Goal: Create ambient, smeared drum texture

Settings:

  • Mode: Spectral blur
  • Phase_amount: 35
  • Stereo_width: 0.15

Result: Drums with reduced transient sharpness, washy character

Advanced Techniques

Layered processing:
  • Multiple passes: Process same sound with different modes
  • Parameter automation: Vary Phase_amount over time for moving effects
  • Frequency splitting: Process different frequency ranges separately
  • Mix blending: Blend processed and dry signals

Combine phase manipulation with other processing for complex results

Creative applications:
  • Artificial spaces: Use phase differences to create spatial impressions
  • Spectral morphing: Process different sounds with same parameters
  • Phase vocoding: Extreme settings for granular-like effects
  • Educational tool: Demonstrate phase perception and effects

Troubleshooting Common Issues

Problem: Effect too subtle
Cause: Low Phase_amount, certain source material
Solution: Increase Phase_amount, try different modes
Problem: Mono compatibility issues
Cause: Extreme phase differences between L/R
Solution: Reduce Stereo_width, check in mono
Problem: Unpleasant artifacts
Cause: Too high Phase_amount, certain frequencies
Solution: Reduce Phase_amount, try different mode
Problem: Loss of transient clarity
Cause: Spectral blur mode, high Phase_amount
Solution: Use Comb or Formant modes, lower Phase_amount

Technical Deep Dive

FFT Processing Details

Spectrum to Matrix Conversion

Praat's FFT representation:

Spectrum object: complex frequency data Matrix conversion: 2 rows × n frequency bins Row 1: real components (cosine terms) Row 2: imaginary components (sine terms) Frequency bin mapping: bin 1: DC component (0Hz) bin 2: Fs/N Hz (Fs = sample rate, N = FFT size) bin k: (k-1)·Fs/N Hz bin N/2+1: Nyquist frequency (Fs/2) Phase manipulation applies to all bins except DC DC component (bin 1) typically left unchanged

Inverse FFT Reconstruction

Returning to time domain:

Modified matrix → Spectrum object Spectrum → Sound (inverse FFT) Important: Phase manipulation preserves magnitude spectrum Input magnitude ≈ output magnitude Only phase relationships changed Time domain result: Same overall frequency content Different phase relationships between components Different waveform shape Possibly different perceived timbre Stereo reconstruction: Left and right channels reconstructed separately Then combined into stereo sound

Psychoacoustic Considerations

Phase Perception Limits

Human phase sensitivity:

Phase perception varies by frequency: Low frequencies (< 500Hz): Good phase sensitivity Can detect phase differences between ears (directional cues) Can detect phase relationships between harmonics Mid frequencies (500-2000Hz): Moderate phase sensitivity Some directional phase cues Less sensitivity to harmonic phase High frequencies (> 2000Hz): Poor phase sensitivity Directional cues based on amplitude, not phase Insensitive to harmonic phase relationships This script works across all frequencies But effects may be more audible in low-mid range

Mono Compatibility

Phase cancellation in mono:

Stereo: L and R played separately Mono: L and R summed together If L and R have large phase differences: Stereo: wide image, phase effects Mono: possible cancellations where L and R out of phase Example: L = A·cos(ωt + φ) R = A·cos(ωt + φ + Δ) Mono sum = 2A·cos(ωt + φ + Δ/2)·cos(Δ/2) Cancellation when cos(Δ/2) ≈ 0 → Δ ≈ π (180°) Solution: Moderate Stereo_width values Avoid extreme phase differences that cause cancellation