Wave Interference Pattern — User Guide

Spectral interference processing: applies mathematical wave interference patterns directly to frequency domain data using matrix operations, creating complex comb filtering, phasing, and spectral modulation effects with real-time performance.

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

What this does

This script implements spectral wave interference processing — a novel approach that applies mathematical interference patterns directly to audio spectra using fast matrix operations. Unlike traditional time-domain effects, this works in the frequency domain to create complex comb filtering, spectral notching, and phasing effects that would be computationally prohibitive in the time domain. The process involves: (1) Frequency domain conversion: Transform audio to spectrum using FFT. (2) Matrix representation: Convert spectrum to matrix for mathematical manipulation. (3) Interference application: Apply sine/cosine wave patterns to create spectral modulation. (4) Frequency-dependent processing: Limit effects to specified frequency range with brightness compensation. (5) Efficient reconstruction: Convert back to audio with proper timing preservation.

Key Features:

What is spectral interference processing? Traditional audio effects work in the time domain, manipulating waveforms directly. Spectral interference works in the frequency domain, manipulating the distribution of energy across frequencies. Benefits: (1) Complex patterns: Create effects impossible in time domain. (2) Precise control: Target specific frequency regions. (3) Computational efficiency: Matrix operations are extremely fast. (4) Novel textures: Generate unique sonic characteristics. (5) Physical modeling: Mathematically similar to acoustic interference phenomena. This approach is particularly effective for creating comb filtering, phasing, spectral flanging, and alien-like transformations that maintain the original timing and rhythm of the source material.

Technical Implementation: (1) Spectral conversion: Use Praat's FFT to convert time-domain audio to frequency-domain spectrum. (2) Matrix conversion: Transform spectrum to matrix representation for mathematical operations. (3) Interference formula: Apply |sin(col/A) + weight×cos(col/B)| pattern to spectral magnitudes. (4) Frequency limiting: Only process frequencies below cutoff to prevent aliasing artifacts. (5) Brightness compensation: Apply high-frequency boost to counteract spectral darkening. (6) Signal reconstruction: Convert matrix back to spectrum, then to audio, with proper sample rate and duration correction. Processing is nearly instantaneous due to optimized matrix mathematics.

Quick start

  1. In Praat, select exactly one Sound object.
  2. Run script…wave_interference_pattern.praat.
  3. Choose Preset from dropdown:
    • Default: Balanced interference effect
    • Strong Interference: Pronounced comb filtering
    • Subtle Interference: Gentle spectral modulation
    • Alien Radio: Extreme metallic transformation
    • Phaser: Smooth phase-shift effects
  4. Or select Custom and adjust:
    • Frequency_cutoff_hz: Maximum affected frequency
    • Sine_divisor: Sine wave pattern density
    • Cosine_divisor: Cosine wave pattern density
    • Cosine_weight: Cosine pattern intensity
    • Brightness_compensation: High-frequency boost
  5. Set Scale_peak (0.99 recommended)
  6. Enable Play_after_processing for immediate audition
  7. Enable Keep_original to preserve source
  8. Click OK — processed sound created with "_Interference" suffix
Quick tip: Start with presets to understand different interference characters. For subtle effects: use Subtle Interference on vocals or acoustic instruments. For dramatic transformation: use Alien Radio on drums or full mixes. For classic effects: use Phaser on guitars or synths. The processing is extremely fast — ideal for real-time experimentation. Lower Frequency_cutoff_hz values create more pronounced effects in the audible range. Higher Brightness_compensation prevents the "muffled" sound that can occur with spectral processing.
Important: SPECTRAL PROCESSING — effects work by modifying frequency content, not time-domain waveforms. Frequency_cutoff_hz: Very low cutoffs (<1000Hz) may remove most audible content. Divisor parameters: Very small values (<100) create extreme aliasing-like effects. Brightness compensation: Values >2.0 can introduce harsh high frequencies. Matrix reconstruction: The FFT process adds padding — output duration matches original but internal timing may vary slightly. Extreme settings: Can create metallic, robotic, or completely transformed sounds. Original preservation: "Keep_original=0" removes source sound — use with caution.

Interference Theory

Wave Interference Fundamentals

Physical Interference Phenomena

Acoustic wave interference:

PHYSICAL INTERFERENCE: When two waves meet, they combine through superposition Constructive interference: Peaks align → louder sound Destructive interference: Peak meets trough → quieter sound Mathematical representation: Wave₁ = A × sin(ω₁t + φ₁) Wave₂ = B × sin(ω₂t + φ₂) Result = Wave₁ + Wave₂ Spectral consequences: Regular interference patterns create comb filtering Frequency-dependent amplification and attenuation Characteristic "notched" frequency response Our digital implementation: Instead of time-domain wave addition We apply interference patterns directly to frequency spectrum Creates similar perceptual effects much more efficiently

Spectral vs Temporal Processing

Domain comparison:

🎛️ Processing Domain Differences

Time Domain Processing (Traditional):

  • Operations: Waveform manipulation, filtering, modulation
  • Effects: EQ, compression, distortion, chorus, flanger
  • Advantages: Intuitive, preserves phase relationships
  • Limitations: Computationally expensive for complex spectral effects

Frequency Domain Processing (This Script):

  • Operations: Spectral magnitude manipulation, pattern application
  • Effects: Comb filtering, spectral notching, alien transformations
  • Advantages: Extremely fast, precise frequency control
  • Limitations: Phase relationships may be affected

Our Hybrid Approach: Convert to frequency domain, apply patterns, convert back with timing correction

Interference Mathematics

Core Interference Formula

Spectral pattern generation:

INTERFERENCE PATTERN FORMULA: pattern = |sin(col / sine_divisor) + cosine_weight × cos(col / cosine_divisor)| Where: col = frequency bin index (0 to number_of_bins) sine_divisor = controls sine wave density cosine_divisor = controls cosine wave density cosine_weight = relative strength of cosine component Properties: - Absolute value ensures non-negative magnitudes - Sine component creates primary interference pattern - Cosine component adds secondary complexity - Combined creates rich, evolving spectral modulation Frequency interpretation: col represents frequency: frequency = col × bin_width Therefore: sin(col/A) = sin(frequency / (A × bin_width)) The pattern repeats across frequency spectrum Musical effects: Creates series of spectral peaks and nulls Similar to comb filtering but more complex Can emulate phasing, flanging, and resonant effects

Pattern Visualization

Interference Pattern Examples

Simple Sine Pattern (cosine_weight=0):
|sin(col/800)| pattern:
Peaks at: col=400, 1200, 2000...
Nulls at: col=800, 1600, 2400...

Combined Pattern (cosine_weight=0.5):
|sin(col/800) + 0.5×cos(col/1200)|:
Complex peaks at irregular intervals
Richer, more musical interference

Alien Pattern (cosine_weight=0.9):
|sin(col/150) + 0.9×cos(col/160)|:
Very dense, metallic character
Extreme spectral modulation

Each pattern creates unique sonic character

Frequency Domain Considerations

Bin-Based Processing

Spectral resolution:

FFT BIN CALCULATION: bin_width = sampling_rate / (2 × number_of_bins) number_of_bins = FFT_size / 2 (for real signals) Our processing: col ranges from 1 to number_of_bins frequency = (col - 1) × bin_width Cutoff calculation: cutoff_bin = round(frequency_cutoff_hz / bin_width) Only bins 1 to cutoff_bin are processed Higher bins pass through unchanged Why limit frequency range? - Prevents aliasing artifacts in high frequencies - Reduces processing time - Allows focused effect on audible range - Prevents ultrasonic content distortion Typical values (44.1kHz sampling): bin_width ≈ 21.5Hz (2048-point FFT) cutoff_bin = 11000Hz / 21.5Hz ≈ 512 bins

Brightness Compensation

Spectral tilt correction:

Brightness Compensation Mechanism:

Problem: Spectral processing often reduces high frequencies
Interference patterns can create "muffled" or "dark" results

Solution: Apply frequency-dependent gain boost
Formula: gain = 1 + (col/total_bins) × (brightness - 1)

How it works:
- Low frequencies: minimal boost (×1.0)
- Mid frequencies: moderate boost
- High frequencies: maximum boost (×brightness)

Examples:
brightness=1.2: 20% high-frequency boost
brightness=1.5: 50% high-frequency boost
brightness=2.0: 100% high-frequency boost

Result: Preserves high-frequency content and clarity

Matrix Processing Algorithm

Spectral Conversion Pipeline

FFT Processing Chain

Domain transformation steps:

PROCESSING PIPELINE: STEP 1: Time Domain → Spectrum selectObject: sound spectrum = To Spectrum: "yes" Why "yes" for fast? Uses FFT for speed over accuracy STEP 2: Spectrum → Matrix mat_src = To Matrix Converts complex spectrum to real-valued matrix Matrix dimensions: time × frequency STEP 3: Matrix Processing Apply interference pattern formula Only process frequencies below cutoff Apply brightness compensation STEP 4: Matrix → Spectrum spec_out = To Spectrum Convert back to complex spectral representation STEP 5: Spectrum → Time Domain sound_tmp = To Sound FFT reconstruction creates time-domain signal STEP 6: Timing Correction Override sampling frequency: original_sr Extract part: 0, original_dur, "rectangular", 1, "no" Result: Processed audio with original timing

Matrix Formula Construction

Dynamic formula generation:

FORMULA CONSTRUCTION: The script builds a formula string dynamically: "if col < " + cutoff_bin$ + " then self * (abs(sin(col / " + sine_divisor$ + ") + " + cosine_weight$ + " * cos(col / " + cosine_divisor$ + "))) * (1 + (col/" + total_bins$ + ") * (" + brightness$ + " - 1))" + " else self fi" Component breakdown: "if col < cutoff_bin": Only process low frequencies "abs(sin(col/sine_divisor)": Primary interference pattern "+ cosine_weight * cos(col/cosine_divisor)": Secondary pattern "* (1 + (col/total_bins) * (brightness - 1))": High-frequency boost "else self": Pass high frequencies unchanged Why string construction? - Praat's Formula requires literal strings - Allows dynamic parameter insertion - More efficient than multiple Formula calls - Single-pass processing

Timing and Reconstruction

FFT Artifact Management

Common FFT issues and solutions:

FFT Processing Challenges:

Problem 1: Incorrect Sample Rate
FFT reconstruction may use wrong sampling rate
Solution: Override sampling frequency: original_sr

Problem 2: Duration Padding
FFT adds zeros to reach power-of-two length
Solution: Extract part: 0, original_dur

Problem 3: Phase Distortion
Magnitude-only processing affects phase relationships
Solution: Use rectangular window for extraction

Problem 4: Time Smearing
FFT windowing can blur transients
Solution: Fast FFT with minimal windowing

Our Approach: Balance between speed and quality
Fast processing for experimentation
Adequate quality for most musical applications

Performance Optimization

Matrix processing advantages:

WHY MATRIX PROCESSING IS FAST: Single Formula Application: Traditional approach: Process each frequency bin individually Matrix approach: Single formula applied to entire matrix Performance: O(1) formula evaluation vs O(n) loop Vectorized Operations: Modern CPUs optimized for matrix math SIMD (Single Instruction Multiple Data) processing Parallel computation of multiple frequency bins Memory Efficiency: Single matrix object vs multiple temporary objects Reduced memory allocation overhead Cache-friendly sequential memory access Praat Optimization: Formula evaluation highly optimized in Praat Matrix operations use efficient C++ backend Minimal interpretation overhead Result: Near-instant processing even for long files Typical processing time: <1 second for 1-minute audio Enables real-time experimentation and parameter tweaking

Complete Processing Pipeline

PHASE 1: SETUP & ANALYSIS Validate selection (exactly 1 sound) Apply preset parameters or use custom Measure original sampling rate and duration Convert to spectrum using FFT PHASE 2: FREQUENCY DOMAIN CONVERSION Calculate bin width and total bins Compute cutoff bin from frequency cutoff Convert spectrum to matrix representation PHASE 3: INTERFERENCE PROCESSING Construct dynamic formula string Apply interference pattern to matrix Limit processing to frequencies below cutoff Apply brightness compensation PHASE 4: SIGNAL RECONSTRUCTION Convert matrix back to spectrum Convert spectrum to time-domain audio Correct sampling rate to match original Trim to original duration PHASE 5: OUTPUT MANAGEMENT Apply descriptive naming Scale peak to prevent clipping Clean up temporary objects Optional: Remove original sound OUTPUT: Processed audio with interference effects Maintains original timing and rhythm All temporary objects cleaned up Ready for playback or further processing

Pattern Presets

Default

ParameterValueSonic Character
Sine_divisor800Medium pattern density
Cosine_divisor1200Secondary complexity
Cosine_weight0.5Balanced pattern mix
Brightness_compensation1.2Moderate high-frequency boost
EffectBalancedMusical comb filtering

🎵 Default Characteristics

Sonic character: Balanced comb filtering with musical spectral modulation

Best for: General purpose, vocals, instruments, full mixes

Technical notes: Medium pattern density creates audible but not overwhelming effects, balanced cosine contribution adds complexity without extreme transformation, moderate brightness compensation maintains clarity

Strong Interference

ParameterValueSonic Character
Sine_divisor400Dense pattern
Cosine_divisor600Complex secondary
Cosine_weight0.8Strong cosine influence
Brightness_compensation1.5Significant high-frequency boost
EffectPronouncedObvious spectral notching

🎛️ Strong Interference Characteristics

Sonic character: Pronounced comb filtering with obvious spectral peaks and nulls

Best for: Sound design, dramatic effects, electronic music

Technical notes: Dense patterns create closely spaced spectral notches, strong cosine weight adds complex modulation, significant brightness compensation counters the strong filtering effect

Subtle Interference

ParameterValueSonic Character
Sine_divisor1200Sparse pattern
Cosine_divisor2000Very subtle secondary
Cosine_weight0.2Minimal cosine influence
Brightness_compensation1.1Very gentle high-frequency boost
EffectSubtleGentle spectral shaping

🎚️ Subtle Interference Characteristics

Sonic character: Gentle spectral modulation that enhances without overwhelming

Best for: Subtle enhancement, acoustic instruments, vocals, mastering

Technical notes: Sparse patterns create broad, gentle spectral shaping, minimal cosine contribution maintains transparency, very gentle brightness compensation preserves natural character

Alien Radio

ParameterValueSonic Character
Sine_divisor150Extremely dense pattern
Cosine_divisor160Similar dense secondary
Cosine_weight0.9Very strong cosine influence
Brightness_compensation2.0Maximum high-frequency boost
EffectExtremeMetallic, robotic transformation

Phaser

ParameterValueSonic Character
Sine_divisor2000Very sparse pattern
Cosine_divisor2005Slightly different secondary
Cosine_weight1.0Equal cosine influence
Brightness_compensation1.0No high-frequency boost
EffectSmoothPhase-shift like modulation
Preset Selection Guide:
  • Default: All-purpose musical interference
  • Strong Interference: Dramatic comb filtering effects
  • Subtle Interference: Gentle spectral enhancement
  • Alien Radio: Extreme metallic transformation
  • Phaser: Smooth phase-shift style effects

Parameters & Settings

Interference Parameters

ParameterRangeDefaultDescription
Frequency_cutoff_hz100-2000011000Maximum affected frequency
Sine_divisor50-5000800Sine pattern density
Cosine_divisor50-50001200Cosine pattern density
Cosine_weight0.0-2.00.5Cosine pattern intensity

Tone Parameters

ParameterRangeDefaultDescription
Brightness_compensation0.5-3.01.2High-frequency boost amount

Output Parameters

ParameterRangeDefaultDescription
Scale_peak0.1-1.00.99Final peak normalization
Play_after_processingboolean1Auto-play after processing
Keep_originalboolean1Preserve source sound

Parameter Guidance

Divisor parameter relationships:
  • Similar divisors (800/850): Creates beating patterns
  • Very different divisors (200/2000): Creates complex multi-scale patterns
  • Very small divisors (50-200): Creates dense, metallic effects
  • Large divisors (1000-5000): Creates broad, gentle shaping
  • Prime number ratios: Creates non-repeating, complex patterns
Cosine_weight effects:
  • 0.0: Pure sine pattern (simple comb filtering)
  • 0.2-0.5: Balanced complexity (musical)
  • 0.6-0.8: Strong cosine influence (rich patterns)
  • 0.9-1.0+: Dominant cosine (extreme transformation)
Frequency_cutoff_hz selection:
  • 1000-3000Hz: Focus on vocal/formant range
  • 3000-8000Hz: Focus on presence and clarity
  • 8000-12000Hz: Focus on brightness and air
  • 12000-20000Hz: Full spectrum processing
  • <5000Hz: Extreme low-frequency focus

Applications

Sound Design

Use case: Creating metallic, robotic, or alien sounds

Technique: Use Alien Radio preset with various sources

Results: Extreme spectral transformation, metallic resonances, sci-fi effects

Vocal Processing

Use case: Adding character and presence to vocals

Technique: Use Subtle Interference or Phaser presets

Benefits: Gentle formant enhancement, added presence, vintage character

Drum Enhancement

Use case: Adding punch and character to drums

Technique: Use Strong Interference on drum buses

Results: Enhanced attack, added ring and sustain, punchy character

Creative Effects

Use case: Experimental and textural processing

Technique: Extreme parameter settings with various sources

Results: Unique spectral textures, experimental sounds, audio art

Practical Workflow Examples

🎤 Vocal Presence Enhancement

Goal: Add character and presence to vocal recordings

Setup:

  • Preset: Subtle Interference or Phaser
  • Source: Lead vocal recording
  • Adjustment: Lower Frequency_cutoff_hz to 5000-8000Hz
  • Result: Enhanced vocal presence with vintage character

Tip: Blend with dry signal for subtle enhancement

🥁 Drum Texture Creation

Goal: Add metallic ring and sustain to drums

Setup:

  • Preset: Strong Interference or Alien Radio
  • Source: Drum bus or individual drums
  • Adjustment: Use parallel processing for controlled effect
  • Result: Punchy drums with enhanced character

Tip: Lower Cosine_weight for more predictable results

🎹 Synthetic Texture Generation

Goal: Create evolving synthetic textures

Setup:

  • Preset: Alien Radio with extreme settings
  • Source: Simple synth pads or noise
  • Adjustment: Experiment with prime number divisors
  • Result: Complex, evolving synthetic textures

Tip: Process multiple times with different settings

Advanced Techniques

Multi-stage interference:
  • Stage 1: Subtle Interference for gentle shaping
  • Stage 2: Strong Interference for pronounced effects
  • Stage 3: Alien Radio for extreme transformation
  • Result: Complex, layered spectral character
Frequency-focused processing:
  • Low cutoffs (1000-3000Hz): Formant and vocal range effects
  • Medium cutoffs (3000-8000Hz): Presence and clarity enhancement
  • High cutoffs (8000-20000Hz): Air and brightness effects
  • Multiple passes: Different cutoffs for different frequency ranges

Troubleshooting Common Issues

Problem: Output sounds "muffled" or "dark"
Cause: Insufficient brightness compensation or too low frequency cutoff
Solution: Increase Brightness_compensation, raise Frequency_cutoff_hz, or use presets with higher brightness
Problem: Extreme metallic/aliasing artifacts
Cause: Very small divisor values or very high cosine weight
Solution: Increase divisor values, reduce cosine weight, or lower frequency cutoff
Problem: No audible effect
Cause: Too high divisor values or too low frequency cutoff
Solution: Decrease divisor values, raise frequency cutoff, or increase cosine weight
Problem: Phasey or swirling artifacts
Cause: Very similar divisor values creating beating patterns
Solution: Use more different divisor values or reduce cosine weight

Algorithmic Extensions

Advanced Interference Patterns

Complex Pattern Generation

Beyond basic sine/cosine:

ADVANCED PATTERN FORMULAS: MULTI-WAVE INTERFERENCE: pattern = |sin(col/A) + w1×cos(col/B) + w2×sin(col/C)| Three-wave interference for richer patterns More complex spectral modulation FREQUENCY-DEPENDENT WEIGHTS: pattern = |sin(col/A) + (col/total)×cos(col/B)| Cosine influence increases with frequency Creates evolving spectral character RANDOMIZED PATTERNS: pattern = |sin(col/A) + w×cos(col/B) + noise(col)| Adds stochastic elements Creates organic, non-repeating patterns WAVETABLE-BASED PATTERNS: pattern = wavetable[mod(col, table_size)] Use any arbitrary waveform Maximum creative control Benefits: More complex and musical results Richer spectral modulation More control over sonic character Endless creative possibilities

Time-Varying Interference

Dynamic Spectral Processing

Evolving patterns over time:

TIME-VARYING APPROACHES: APPROACH 1: Parameter Automation Vary divisors over time: A(t), B(t) Create evolving interference patterns Similar to phaser or flanger modulation APPROACH 2: Multi-band Processing Split into time segments Apply different patterns to each segment Create evolving spectral character APPROACH 3: Envelope Following Modulate parameters based on input level Create dynamic, responsive effects More musical and natural APPROACH 4: Random Walks Parameters follow random walks within bounds Creates organic, unpredictable evolution Great for generative music Implementation: Process in segments or use Praat's Formula with time variable

Phase-Aware Processing

Complex Spectrum Manipulation

Beyond magnitude-only processing:

COMPLEX SPECTRUM PROCESSING: Current: Magnitude-only processing We process |spectrum| but ignore phase Efficient but affects phase relationships Advanced: Complex spectrum processing Process real and imaginary parts separately Maintain phase relationships More natural sounding results Phase-aware interference: real_out = real × pattern(real) imag_out = imag × pattern(imag) Or use different patterns for real/imag Phase correction: Calculate phase: φ = atan2(imag, real) Process magnitude: |spectrum| × pattern Reconstruct: real = |spectrum| × cos(φ), imag = |spectrum| × sin(φ) Benefits: More natural sounding processing Preserves transient information better Maintains phase coherence Higher quality results