Spectral Panning Filter — User Guide
Frequency-based stereo separation: splits audio spectrum at a cutoff frequency, sending low frequencies to left channel and high frequencies to right channel for spectral panning effects.
What this does
This script implements spectral panning — a frequency-based stereo separation technique that splits the audio spectrum at a user-defined cutoff frequency. Process: (1) Takes stereo input (converts mono to stereo if needed), (2) Separates into left/right channels, (3) Converts each channel to frequency domain via FFT, (4) Applies complementary filters: Left channel keeps frequencies < cutoff, Right channel keeps frequencies > cutoff, (5) Reconstructs filtered channels to time domain, (6) Combines into final stereo output with spectral panning effect.
Key Features:
- Frequency-Based Panning — Low frequencies panned left, high frequencies panned right
- Adjustable Crossover — User-defined cutoff frequency (default 500Hz)
- Mono Compatibility — Automatically converts mono inputs to stereo
- Zero Latency — Offline processing, no real-time constraints
- Rectangular Filters — Sharp cutoff at specified frequency
- Duration Preservation — Maintains original timing despite FFT padding
Technical Implementation: (1) Input handling: Stores original duration, copies sound, converts mono→stereo if needed. (2) Channel separation: Extracts left/right channels as separate Sound objects. (3) Frequency domain conversion: Converts each channel to Spectrum with padding ("yes" for FFT windowing). (4) Spectral filtering: Applies complementary formulas: Left spectrum keeps x < freq, zeroes x ≥ freq. Right spectrum keeps x > freq, zeroes x ≤ freq. (5) Reconstruction: Converts filtered spectra back to time domain Sounds. (6) Stereo combination: Combines filtered channels into stereo output. (7) Duration correction: Critical step: FFT padding adds extra samples, so extracts original duration portion using rectangular window. (8) Cleanup: Removes temporary objects, preserves only final result.
Quick start
- In Praat, select one Sound object (stereo preferred, mono auto-converted).
- Run script… →
panning_filter.praat. - Set freq parameter (default 500Hz) — crossover frequency.
- Click OK — spectral panning applied.
- Output named "originalname_panned" appears in Objects window.
- Output automatically played for immediate evaluation.
Spectral Panning Theory
Frequency Domain Filtering
Spectral Representation
Sound in frequency domain:
Complementary Filter Design
Left and right channel filters:
📐 Filter Visualization
Left channel (low frequencies):
───────████████████████───────
Keeps: 0Hz to (freq-1)Hz
Discards: freqHz to Nyquist
Right channel (high frequencies):
───────████████████████───────
Discards: 0Hz to freqHz
Keeps: (freq+1)Hz to Nyquist
Gap at cutoff: Frequencies near f_c may be attenuated
FFT Processing Details
Windowing and Padding
Praat's FFT implementation:
Duration Preservation Challenge
The FFT padding problem:
Duration = N / Fs seconds
FFT with padding: N' samples (power of 2 ≥ N)
Duration' = N' / Fs seconds
Longer than original due to padding
Solution in script:
1. Store original duration: originalDur = Get total duration
2. Process with padding (FFT needs it)
3. After reconstruction: Extract part: 0, originalDur
4. Rectangular window, no fading
Result: Output matches original timing
Padding artifacts removed
FFT windowing effects still present at edges
Stereo Perception Effects
Spatial Frequency Distribution
How brain interprets spectral panning:
Cutoff Frequency Selection
Psychoacoustic considerations:
Mathematical Implementation
Spectral Filtering Formulas
Praat Formula syntax:
FFT Bin Alignment
Discrete frequency bins:
Processing Workflow
Step-by-Step Processing
📥 Step 1: Input Preparation
Actions:
- Store original name and duration
- Create temporary copy of sound
- Check channel count
- Convert mono to stereo if needed
Code:
🎛️ Step 2: Channel Separation
Actions:
- Extract left and right channels as separate Sounds
- Prepare for independent processing
Code:
📊 Step 3: Frequency Domain Conversion
Actions:
- Convert each channel to Spectrum with windowing
- Apply FFT with padding
Code:
✂️ Step 4: Spectral Filtering
Actions:
- Apply low-pass filter to left channel spectrum
- Apply high-pass filter to right channel spectrum
- Complementary filtering creates panning effect
Code:
🔄 Step 5: Time Domain Reconstruction
Actions:
- Convert filtered spectra back to Sounds
- Inverse FFT transforms frequency→time
Code:
🎧 Step 6: Stereo Combination & Duration Correction
Actions:
- Combine filtered channels into stereo sound
- Extract original duration to remove FFT padding
- Rename with descriptive name
Code:
🧹 Step 7: Cleanup & Playback
Actions:
- Remove temporary objects
- Play result for immediate evaluation
- Leave final sound selected
Code:
Flowchart Summary
Parameters & Effects
Core Parameter
| Parameter | Type | Default | Description |
|---|---|---|---|
| freq | positive | 500 | Cutoff frequency in Hz (crossover point) |
Frequency Range Recommendations
| Application | Frequency Range | Effect Description |
|---|---|---|
| Sub-bass isolation | 80-150 Hz | Extreme low frequencies in left channel only |
| Bass separation | 150-300 Hz | Bass instruments left, everything else right |
| Voice/music separation | 300-800 Hz | Voice fundamentals left, harmonics right |
| Mid-range panning | 800-2000 Hz | Musical instrument separation |
| Brightness separation | 2000-5000 Hz | High harmonics/sibilance in right channel |
| Air/brilliance | 5000-10000 Hz | Ultra-high frequencies isolated right |
Automatic Parameters
- Windowing: Always "yes" (Hann window applied)
- FFT size: Automatic power-of-2 padding
- Extraction method: "rectangular" window (no fade)
- Preserve times: "no" (extract from time 0)
- Channel handling: Auto mono→stereo conversion
Expected Effects by Frequency
🔊 100 Hz Cutoff
Left channel: Only sub-bass (kick drum fundamental, bass guitar rumble)
Right channel: Everything else (mid/high frequencies)
Perception: Extreme separation, bass completely isolated left
Best for: Experimental effects, bass emphasis
🎤 500 Hz Cutoff (Default)
Left channel: Bass and lower midrange (fundamentals)
Right channel: Upper midrange and highs (harmonics, brightness)
Perception: Natural-sounding separation, good for music
Best for: General purpose, musical material
🎸 2000 Hz Cutoff
Left channel: Most musical fundamentals (bass, guitar, voice body)
Right channel: High harmonics, cymbals, sibilance
Perception: Brightness separated right, body left
Best for: Enhancing stereo width without losing center
Applications
Creative Mixing
Use case: Unconventional stereo imaging for artistic effect
Technique: Use moderate cutoff (500-1000Hz) on full mixes
Example: Entire track processed → bass elements left, vocals/cymbals right
Sound Design
Use case: Creating artificial width from mono sources
Technique: Process mono sounds with varying cutoff frequencies
Workflow:
- Create multiple versions with different cutoffs
- Layer them with different panning
- Automate cutoff for moving spectral effects
Analytical Listening
Use case: Hearing frequency distribution spatially
Technique: Sweep cutoff frequency while listening
Application: Identify frequency ranges of different instruments
Educational Tool
Use case: Teaching frequency perception and stereo imaging
Advantages:
- Demonstrates frequency ranges audibly
- Shows FFT filtering effects
- Illustrates stereo perception principles
- Hands-on experience with spectral processing
Therapeutic Applications
Use case: Binaural frequency separation for audio therapy
Technique: Different frequencies to different ears
Example: Soothing low frequencies left, stimulating highs right
Practical Workflow Examples
🎵 Music Production - Wide Stereo Bass
Goal: Create unusual stereo image with bass isolated
Settings:
- Cutoff: 200 Hz
- Process: Full music track
Result: Kick/bass completely left, everything else right
Creative use: Blend with dry signal for enhanced width
🎤 Vocal Processing - Sibilance Control
Goal: Separate vocal sibilance from body
Settings:
- Cutoff: 4000 Hz
- Process: Vocal track only
Result: Vocal body left, sibilance/air right
Creative use: De-ess by attenuating right channel
🎧 Headphone Testing - Frequency Check
Goal: Test headphone frequency response balance
Settings:
- Cutoff: 1000 Hz
- Process: Pink noise
Result: Low/mids left, highs right
Diagnostic use: Identify L/R imbalances in playback system
Advanced Techniques
- Multiple cutoffs: Process same sound with different frequencies
- Inverted panning: Modify script to swap L/R filtering
- Frequency sweep: Automate cutoff over time
- Mid-side conversion: Process M/S encoded material
Combine with other processing for complex spectral effects
- Gentler slopes: Change rectangular filters to gradual
- Band-pass variants: Keep mid frequencies, discard extremes
- Multi-band: Split into more than two bands
- Dynamic cutoff: Cutoff follows envelope or pitch
Customize for specific applications
Troubleshooting Common Issues
Cause: FFT windowing artifacts, rectangular extraction
Solution: Normal, expected with FFT processing. Can fade in/out manually if problematic.
Cause: Cutoff too high/low for material, narrow frequency content
Solution: Try different cutoff, use full-spectrum source material
Cause: Extreme spectral separation, FFT phase shifts
Solution: Check mono compatibility, use moderate cutoff
Cause: Script bug - duration extraction not working
Solution: Ensure "Extract part: 0, originalDur" executes correctly
Comparison with Other Techniques
| Technique | Method | Pros | Cons | Best For |
|---|---|---|---|---|
| Spectral Panning (this script) | Frequency-based L/R separation | Unique effect, frequency control | Phase issues, FFT artifacts | Creative effects, sound design |
| Amplitude Panning | Volume balance between channels | Natural, standard technique | All frequencies move together | Traditional mixing |
| Haas Effect | Time delays between channels | Wide stereo, psychoacoustic | Mono compatibility issues | Widening, spatial effects |
| Mid-Side Processing | M/S encoding then processing | Flexible, preserves mono | More complex setup | Professional mixing |
Technical Notes
FFT Considerations
Windowing Trade-offs
Hann window effects:
Padding and Duration
Why padding matters:
Input: N samples (any number)
FFT: N' = next power of 2 ≥ N
Example: 30000 samples → 32768 (2^15)
2776 zero samples added (padding)
Duration change:
Original: duration = N/Fs
Padded: duration' = N'/Fs > duration
Script solution:
1. Store originalDur = N/Fs
2. Process with padding (needed for FFT)
3. Extract: 0 to originalDur (removes padding)
Edge effects:
Windowing affects start/end anyway
Padding removal creates sharp cut
May cause clicks at boundaries
Filter Characteristics
Rectangular Filter Response
Frequency and time domain effects:
Phase Response
Linear phase characteristic: