Harmonic Spray / Partial Panner — User Guide

Spectral stereo imaging: pans different frequency bands across the stereo field for enhanced width and spatial distribution.

Author: Based on Praat AudioTools by Shai Cohen Version: 2025 Process: Mono → Stereo frequency-based panning
Contents:

What this does

This script implements harmonic spray / partial panning — a sophisticated spectral stereo imaging technique that distributes different frequency bands across the stereo field. The process: (1) Frequency analysis: Split audio into logarithmically-spaced frequency bands, (2) Spatial mapping: Assign each band to stereo positions based on frequency, (3) Panning application: Apply constant-power panning to each band, (4) Recombination: Sum all panned bands into stereo output. Result: mono sounds transformed into rich stereo images with frequency-dependent spatial distribution.

Key Features:

What is harmonic spray panning? Traditional stereo: left/right channels with identical frequency content. Harmonic spray: different frequencies placed at different stereo positions. Advantages: (1) Enhanced width: Creates impression of wider stereo image, (2) Spectral separation: Reduces masking between frequency components, (3) Mono compatibility: Maintains phase coherence for bass frequencies, (4) Natural sound: Mimics how humans localize different frequencies, (5) Creative possibilities: Can create "inside-out" or custom spectral distributions. Use cases: Music production (stereo enhancement), sound design (spatial textures), mastering (width control), audio restoration (mono-to-stereo conversion), experimental music (spectral spatialization).

Technical Implementation: (1) Band splitting: Hann bandpass filters with proportional Q values. (2) Spatial mapping: S-curve distribution through tanh function. (3) Pan law application: Constant-power cosine/sine panning. (4) Frequency weighting: Reduced panning for bass, full panning for treble. (5) Mono protection: User-defined LF cutoff. (6) Level compensation: -3.5dB master trim. (7) Dry/wet mixing: Flexible blend control. Key insight: Frequency → stereo position mapping creates spectral width while maintaining mono compatibility.

Quick start

  1. In Praat, select exactly one Sound object (mono or stereo).
  2. Run script…harmonic_spray.praat.
  3. Choose preset: Standard Spread for general use, Subtle Widening for gentle effect.
  4. Adjust dry/wet mix (1.0 = fully processed, 0.5 = 50/50 blend).
  5. For custom control: modify band count, pan width, bandwidth, and LF protection.
  6. Click OK — processes audio, creates "originalname_spray" stereo output.
Quick tip: Start with Standard Spread preset + 100% wet for typical stereo enhancement. Use Subtle Widening + 50% wet for gentle enhancement. Try Reverse preset for unusual high-left/low-right effects. For vocals, use LF protection 150-200 Hz to keep voice fundamental centered. For full-range material, 8-12 bands usually works well. Processing time increases with band count.
Important: MONO COMPATIBILITY — extreme settings may cause phase issues in mono. Very high band counts (>16) can create artificial "phasiness". Extreme pan width (1.0) places lowest/highest frequencies at hard left/right. Wide bandwidth (>1.0 octave) creates overlapping bands that may cause comb filtering. Always check results in mono for compatibility. Dry/wet mix allows balancing effect intensity. Bass protection frequency critical for maintaining stable low-end in stereo and mono playback.

Spectral Panning Theory

Frequency-Dependent Localization

Human Hearing and Stereo Perception

Psychoacoustic principles:

Human localization cues: - Low frequencies (< 800 Hz): Phase/Time differences - High frequencies (> 1500 Hz): Level/Intensity differences - Mid frequencies: Both phase and level cues Spectral panning rationale: - Bass: Keep centered (phase coherence critical) - Mids: Moderate panning (both cues available) - Highs: Full panning (level cues dominant) This matches how we naturally perceive sound sources: Large sources (bass): harder to localize Small sources (treble): easier to localize

Logarithmic Frequency Scaling

Perceptual frequency distribution:

Linear frequency vs perceptual pitch: Human hearing is logarithmic in frequency Equal musical intervals = equal frequency ratios Logarithmic band calculation: band_center[i] = minFreq × (maxFreq/minFreq)^((i-0.5)/N) Where: minFreq = 80 Hz (practical lower limit) maxFreq = min(0.95×Nyquist, 16000 Hz) N = number_of_bands Example: 8 bands from 80-16000 Hz Band centers: 94, 158, 265, 445, 745, 1250, 2090, 3500 Hz (Approximately equally spaced perceptually)

Constant Power Panning

Pan Law Mathematics

Maintaining perceived loudness:

Constant-power panning: gain_left = cos(pan_angle) gain_right = sin(pan_angle) Where pan_angle ranges [0, π/2] for positions [left, right] Power calculation: left_power = cos²(pan_angle) right_power = sin²(pan_angle) total_power = cos² + sin² = 1 (constant) This ensures equal perceived loudness regardless of position Mapping from linear pan to angle: pan_angle = (normalized_position + 1)/2 × π/2 Where normalized_position ∈ [-1, 1]

-3.5dB Compensation

Why master trim is needed:

When summing multiple panned sources: Each band has power = 1 (constant power panning) With N bands, total power ≈ N This causes overall level increase Solution: Apply master gain reduction Gain = 10^(-3.5/20) ≈ 0.668 (approximately -3.5dB) Rationale: - Compensates for power buildup from multiple bands - Maintains similar loudness to input - Prevents clipping in output - Standard practice in multiband processing

Complete Processing Pipeline

INPUT: Sound object (mono/stereo → converted to mono) STEP 1: FREQUENCY BAND CALCULATION - Determine frequency range: 80 Hz to min(0.95×Nyquist, 16kHz) - Calculate N logarithmically-spaced band centers - For each band, calculate bandwidth based on fractional octave STEP 2: BAND PROCESSING LOOP FOR each band i from 1 to N: BAND EXTRACTION: - Calculate low/high frequencies for bandpass - Apply Hann bandpass filter with proportional Q - Smoothing = bandwidth/6 for gentle slopes PAN CALCULATION: - Normalized position = (i-1)/(N-1) ∈ [0,1] - Apply S-curve mapping: tanh(2.5×(2×pos-1)) - Apply frequency-dependent pan scaling - Apply LF protection scaling if needed - Calculate final pan position ∈ [-1,1] CONSTANT-POWER PANNING: - pan_angle = (pan_position + 1)/2 × π/2 - gain_left = cos(pan_angle) - gain_right = sin(pan_angle) ACCUMULATION: - Multiply filtered band by left gain → add to left accumulator - Multiply filtered band by right gain → add to right accumulator STEP 3: OUTPUT COMBINATION - Combine left/right accumulators to stereo (WET) - Apply -3.5dB master gain compensation - Scale WET by dry_wet_mix - Create DRY stereo (mono centered) - Scale DRY by (1 - dry_wet_mix) - Sum WET + DRY for final output - Normalize to prevent clipping OUTPUT: Stereo sound with frequency-dependent panning

Preset Configurations

Preset 1: Custom

⚙️ Full Parameter Control

Bands: User specified (default: 8)

Pan Width: User specified (default: 0.8)

Bandwidth: User specified (default: 0.5 octaves)

Character: Fully customizable spectral distribution

Best for: Experimental work, specific frequency targeting

Preset 2: Subtle Widening

🎵 Gentle Stereo Enhancement

Bands: 6 (moderate resolution)

Pan Width: 0.5 (50% maximum spread)

Bandwidth: 0.5 octaves (balanced selectivity)

Character: Natural, unobtrusive width enhancement

Best for: Main vocals, acoustic instruments, delicate material

Preset 3: Standard Spread

🎛️ General Purpose Stereo

Bands: 8 (good resolution)

Pan Width: 0.8 (80% maximum spread)

Bandwidth: 0.5 octaves (balanced selectivity)

Character: Noticeable but natural stereo enhancement

Best for: Most musical material, mixes, general audio

Preset 4: Extreme Spray

🔥 Maximum Spectral Separation

Bands: 16 (high resolution)

Pan Width: 1.0 (full left/right spread)

Bandwidth: 0.33 octaves (narrow, selective)

Character: Dramatic, very wide, potentially artificial

Best for: Special effects, synthetic sounds, experimental

Preset 5: Reverse (High→L / Low→R)

🔄 Inverted Spectral Distribution

Bands: 10 (good resolution)

Pan Width: -0.9 (reverse direction, 90% spread)

Bandwidth: 0.5 octaves (balanced selectivity)

Character: Unusual, inside-out, attention-grabbing

Best for: Creative effects, surreal textures, standout elements

Preset 6: Dense Shimmer

✨ High-Frequency Sparkle

Bands: 20 (very high resolution)

Pan Width: 0.7 (70% spread)

Bandwidth: 0.33 octaves (narrow, detailed)

Character: Detailed, sparkling, complex high-end

Best for: Hi-hats, cymbals, bright synths, atmospheric textures

Preset 7: Coarse Texture

🎪 Bold Frequency Blocks

Bands: 4 (low resolution)

Pan Width: 1.0 (full spread)

Bandwidth: 1.0 octaves (wide, overlapping)

Character: Bold, blocky, obvious frequency separation

Best for: Lo-fi effects, aggressive textures, rhythmic material

Preset Visualization

Stereo Position vs Frequency (Low → High):

Subtle Widening: L ←···C···→ R (gentle spread)
Standard Spread: L ←····C····→ R (balanced)
Extreme Spray: L············R (full separation)
Reverse: R ←····C····→ L (inverted)
Dense Shimmer: L·↑·↑·↑·↑·↑·R (detailed highs)
Coarse Texture: L██▌C▐██R (blocky bands)

Note: All presets maintain bass frequencies near center

Technical Enhancements

Enhancement 1: Q-Based Proportional Bandwidth

🎚️ Constant-Q Filtering

Principle: Bandwidth proportional to center frequency

Implementation: Fractional octave bandwidth maintained across spectrum

Benefit: Perceptually consistent frequency resolution

Formula: freq_low = center/√(2^octave), freq_high = center×√(2^octave)

Bandwidth Comparison

0.5 octave bandwidth examples:
Center 100 Hz: 84-119 Hz (35 Hz wide)
Center 1000 Hz: 841-1189 Hz (348 Hz wide)
Center 5000 Hz: 4204-5946 Hz (1742 Hz wide)

Constant absolute bandwidth (for comparison):
Center 100 Hz: 75-125 Hz (50 Hz wide)
Center 1000 Hz: 975-1025 Hz (50 Hz wide) ← Too narrow at high frequencies!
Center 5000 Hz: 4975-5025 Hz (50 Hz wide) ← Much too narrow!

Proportional bandwidth matches human frequency resolution

Enhancement 2: Frequency-Dependent Pan Width

🎛️ Adaptive Spatial Scaling

Principle: Less panning at low frequencies, more at high frequencies

Implementation: Scaling curve: 0.3 (bass) → 1.0 (treble)

Benefit: Natural localization matching human perception

Formula: scale = 0.3 + 0.7 × (log_freq)^0.7

Enhancement 3: S-Curve Spatial Mapping

📈 Perceptually Smooth Distribution

Principle: Non-linear mapping for smoother frequency transitions

Implementation: tanh(2.5×(2×pos-1)) S-curve function

Benefit: Avoids abrupt panning changes between adjacent bands

Visual: Gentle curves instead of linear steps

S-Curve vs Linear Mapping

Linear mapping (8 bands):
Band 1: L····· (position -1.0)
Band 2: ·L···· (position -0.71)
Band 3: ··L··· (position -0.43)
Band 4: ···C·· (position -0.14)
Band 5: ····R· (position +0.14)
Band 6: ·····R (position +0.43)
Band 7: ·····R (position +0.71)
Band 8: ·····R (position +1.0)

S-curve mapping (8 bands):
Band 1: L····· (position -1.0)
Band 2: L····· (position -0.96)
Band 3: ·L···· (position -0.70)
Band 4: ··C··· (position -0.10)
Band 5: ···C·· (position +0.10)
Band 6: ····R· (position +0.70)
Band 7: ·····R (position +0.96)
Band 8: ·····R (position +1.0)

S-curve: more center clustering, smoother transitions

Enhancement 4: Mono-Safe Bass Protection

🔊 Low Frequency Stability

Principle: Bass frequencies kept near center for mono compatibility

Implementation: User-defined cutoff with gradual transition

Benefit: Prevents phase cancellation in mono playback

Formula: scale = (freq/cutoff)² for freq < cutoff

Enhancement 5: Master Pan Law Compensation

📊 Level Management

Principle: Compensate for power buildup from multiple bands

Implementation: -3.5dB gain reduction on wet signal

Benefit: Maintains consistent loudness, prevents clipping

Formula: gain = 10^(-3.5/20) ≈ 0.668

Parameters & Settings

Core Processing Parameters

ParameterTypeDefaultDescription
PresetoptionmenuCustomPredefined configurations
Number_of_bandspositive8Number of frequency bands to process
Pan_widthreal0.8Stereo spread amount (0=mono, 1=full spread)
Bandwidth_octavesreal0.5Bandwidth in fractional octaves
LF_protection_frequencypositive150Bass frequency cutoff for mono protection
Dry_wet_mixreal1.0Mix between dry and processed signals

Parameter Guidelines

Number of bands: 4-6: Coarse, obvious frequency separation 8-12: Balanced, good for most material 16-20: Detailed, for complex textures >20: Very detailed, may cause phasiness Pan width: 0.0: All bands centered (mono-like) 0.3-0.6: Subtle to moderate enhancement 0.7-0.9: Strong stereo effect 1.0: Maximum separation Negative: Reverse direction (high→left, low→right) Bandwidth octaves: 0.25: Very narrow, surgical separation 0.33: Narrow, detailed (1/3 octave) 0.5: Standard, musical (1/2 octave) 1.0: Wide, overlapping bands 2.0: Very wide, minimal separation LF protection frequency: 80-120 Hz: Strong bass protection 150-200 Hz: Standard vocal/music protection 250-400 Hz: Light protection, more mid spread >500 Hz: Minimal protection, maximum spread

Auto-calculated Parameters

Frequency range: minFreq = 80 Hz (fixed lower limit) maxFreq = min(sampling_rate/2 × 0.95, 16000 Hz) Band centers: Logarithmic spacing from minFreq to maxFreq band_center[i] = minFreq × (maxFreq/minFreq)^((i-0.5)/N) Band edges: bandwidth_multiplier = 2^bandwidth_octaves freq_low = center / sqrt(bandwidth_multiplier) freq_high = center × sqrt(bandwidth_multiplier) Smoothing: smoothing_hz = (freq_high - freq_low) / 6 (Gentle filter slopes to reduce artifacts)

Applications

Music Production

Use case: Enhancing stereo width of mono sources

Technique: Apply Standard Spread to vocals, instruments

Example: Mono vocal made stereo while keeping low-mid fundamentals centered

Sound Design

Use case: Creating complex stereo textures from simple sounds

Technique: Use Extreme Spray or Dense Shimmer presets

Example: Turning mono noise into rich stereo atmospheric beds

Mastering

Use case: Controlled stereo enhancement

Technique: Subtle Widening with 20-40% wet mix

Example: Gentle overall width increase without compromising mono

Audio Restoration

Use case: Mono-to-stereo conversion of archival material

Technique: Custom settings matching source characteristics

Example: Converting vintage mono recordings to believable stereo

Practical Workflow Examples

🎤 Vocal Stereo Enhancement

Goal: Add natural stereo width to mono vocal

Settings:

  • Preset: Standard Spread
  • LF protection: 180 Hz
  • Dry/wet: 70%
  • Additional: 12 bands for vocal detail

Result: Vocal with enhanced presence and width, stable low-end

🎹 Synth Pad Texturing

Goal: Create evolving stereo texture from simple synth

Settings:

  • Preset: Dense Shimmer
  • LF protection: 120 Hz
  • Dry/wet: 100%
  • Additional: 24 bands for maximum detail

Result: Rich, constantly moving stereo pad texture

🥁 Drum Mono-to-Stereo

Goal: Convert mono drum loop to stereo

Settings:

  • Preset: Coarse Texture
  • LF protection: 100 Hz
  • Dry/wet: 85%
  • Additional: 6 bands for punchy separation

Result: Stereo drums with kick centered, cymbals spread

Advanced Techniques

Frequency-specific processing:
  • Vocal enhancement: High LF protection (180-250 Hz), more bands for detail
  • Bass instruments: Low LF protection (80-120 Hz), fewer bands
  • Percussion: Medium LF protection (120-150 Hz), wide bandwidth for natural sound
  • Full mixes: Light touch (30-50% wet), Standard Spread preset
  • Special effects: Reverse preset, extreme settings, 100% wet
Creative applications:
  • Automated panning: Process different sections with different presets
  • Frequency-selective effects: Combine with EQ before spraying
  • Layering: Mix heavily sprayed and dry versions
  • Mid-side processing: Extract sides after spraying for further processing
  • Serial processing: Apply multiple spray passes with different settings

Troubleshooting Common Issues

Problem: Sound becomes phasey or hollow
Cause: Too many bands or extreme pan width
Solution: Reduce band count, decrease pan width, increase bandwidth
Problem: Bass disappears in mono
Cause: LF protection too high or extreme panning
Solution: Lower LF protection frequency, reduce pan width for low bands
Problem: Artificial or metallic sound
Cause: Too many narrow bands
Solution: Reduce band count, increase bandwidth, use S-curve mapping
Problem: Output too quiet
Cause: Dry/wet mix too low or extreme settings
Solution: Increase dry/wet mix, check master gain compensation
Problem: Processing very slow
Cause: High band count on long files
Solution: Reduce band count, process shorter segments, use faster presets