Multiband Distortion — User Guide

Frequency‑split distortion: apply different distortion types and amounts to low, mid, and high frequency bands independently for precise spectral control.

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 multiband distortion — a sophisticated distortion effect that splits the audio signal into three frequency bands (low, mid, high), applies different distortion algorithms to each band independently, then recombines them. Key features: (1) Phase‑coherent crossover: Linear‑phase Hann‑band filters for clean band splitting. (2) Three distortion types: Soft Clip (tanh), Hard Clip, and Sine Fold for each band. (3) Independent controls: Drive, distortion type, and gain per band. (4) 5 Built‑in Presets: Warm bass/frizz highs, V‑shape, mid‑range crunch, full fuzz. (5) Visual spectral analysis: Color‑coded band display with spectral comparison.

Key Features:

What is multiband distortion? Traditional distortion applies the same nonlinearity across the entire frequency spectrum, which can cause problems: low frequencies become muddy, mid frequencies lose clarity, and high frequencies become harsh. Multiband distortion splits the signal into frequency bands using crossover filters, applies optimized distortion to each band, then recombines. This allows: (1) Clean low‑end: Gentle saturation on bass, preserving punch. (2) Controlled mids: Focused distortion on vocals/instruments. (3) Tamed highs: Reduced harshness while maintaining detail. Use cases: Mastering‑grade distortion, bass‑heavy music processing, vocal enhancement, sound design with spectral control.

Technical Implementation: (1) Crossover system: Uses Hann‑band filters for phase‑coherent splitting. Low = 0‑Low_Split, Mid = Low_Split‑High_Split, High = High_Split‑Nyquist. (2) Distortion procedures: Three algorithms: Soft Clip (tanh), Hard Clip (conditional clipping), Sine Fold (wavefolding). (3) Gain staging: Independent Drive (pre‑distortion) and Gain (post‑distortion) per band. (4) Mix control: Wet/dry blend from 0‑100%. (5) Visualization: Shows original vs. processed spectra with color‑coded band regions and band‑specific settings display.

Quick start

  1. In Praat, select exactly one Sound object.
  2. Run script…apply_multiband_distortion.praat.
  3. Choose a Preset (overrides sliders) or "Manual" to use sliders.
  4. Set Low_Split_Hz and High_Split_Hz for band boundaries.
  5. Configure each band: Drive, Type, Gain.
  6. Adjust Mix (0‑1 = dry‑wet) and Output_Gain.
  7. Enable Draw_visualization to see spectral analysis.
  8. Click OK — effect applied, result named "originalname_MultiDist_presetname".
Quick tip: Start with Warm Bass / Clean Highs preset for bass‑heavy music. Use Frizz for distorted highs only (guitar sizzle). V‑Shape Destruction emphasizes lows and highs while cleaning mids. Mid‑Range Crunch creates telephone‑like mid‑focus. Full Spectrum Fuzz applies heavy distortion everywhere. Set crossovers based on instrument ranges: Low < 200 Hz (bass/kick), Mid 200‑2500 Hz (vocals/guitar), High > 2500 Hz (cymbals/high harmonics). Soft Clip = smooth analog‑like, Hard Clip = aggressive digital, Sine Fold = complex metallic harmonics. Use Mix < 1.0 for parallel processing. Enable visualization to see band‑specific distortion effects.
Important: PHASE CONSIDERATIONS — Filter‑based splitting introduces phase shifts at crossover points. The script uses linear‑phase‑like Hann‑band filters to minimize this, but some phase cancellation is inevitable. Crossover frequencies must be ordered: Low_Split < High_Split. Extreme Drive values (> 10) can cause aliasing, especially in high band. Sine Fold can create inharmonic content — use sparingly on full‑range material. Band‑specific gain staging is critical — distortion reduces peak levels, may need post‑gain > 1.0. Visualization shows spectral content only — phase relationships not visible. Mix < 1.0 creates parallel processing — can preserve transients while adding distortion.

Multiband Theory

Three‑Band Architecture

🎛️ Band Definition & Crossover

Define crossover frequencies: f_L = Low_Split_Hz f_H = High_Split_Hz f_s = sampling frequency Three bands: 1. LOW BAND (0 ‑ f_L Hz) • Contains: Bass, kick, sub‑frequencies • Typical range: 20‑200 Hz • Distortion goal: Warmth without mud 2. MID BAND (f_L ‑ f_H Hz) • Contains: Vocals, guitars, snare, fundamentals • Typical range: 200‑2500 Hz • Distortion goal: Clarity and presence 3. HIGH BAND (f_H ‑ f_s/2 Hz) • Contains: Cymbals, hi‑hats, harmonics • Typical range: 2500‑20000 Hz • Distortion goal: Sparkle without harshness Crossover design: • Uses Hann‑band filters for smooth transition • Linear‑phase characteristics minimize artifacts • 20 Hz transition bandwidth for smooth crossover

Crossover strategy: The script implements a subtractive crossover system: (1) Create total low‑pass at f_H. (2) Create low band at f_L. (3) Mid band = total low‑pass − low band. (4) High band = original − total low‑pass. This ensures perfect reconstruction when bands are summed without distortion.

Distortion Algorithm Types

Soft Clip (Hyperbolic Tangent)

Algorithm: y = tanh(drive × x) × gain Properties: • Smooth S‑shape curve • Asymptotic limits at ±1 • Continuous derivatives • Natural‑sounding harmonics Implementation: Formula: "tanh(self * " + drive$ + ") * " + gain$ Use cases: • Low band: Warm tube‑like saturation • Mid band: Vocal/instrument warmth • High band: Gentle high‑frequency enhancement

Hard Clip (Conditional Clipping)

Algorithm: if |x| > 1: y = sign(x) × gain else: y = x × gain Implementation (Praat Formula): input$ = "(self * " + drive$ + ")" Formula: "if " + input$ + " > 1 then " + gain$ + " else (if " + input$ + " < -1 then " + neg_gain$ + " else " + input$ + " * " + gain$ + " fi) fi" Properties: • Sharp clipping at ±1 • Creates rich odd harmonics • Can cause aliasing • Aggressive, digital character Use cases: • Extreme distortion effects • Guitar "fuzz" tones • Sound design for harsh textures

Sine Fold (Wavefolding)

Algorithm: y = sin(drive × x) × gain Properties: • Periodic folding creates complex harmonics • Can create inharmonic content • Metallic, "FM‑like" character • More complex than simple clipping Implementation: Formula: "sin(self * " + drive$ + ") * " + gain$ Wavefolding behavior: • Input beyond ±π/(2×drive) folds back • Creates intermodulation products • Rich in both even and odd harmonics Use cases: • Experimental sound design • Metallic percussion enhancement • Mid‑range "crunch" with complex texture

Phase‑Coherent Crossover Implementation

🔀 Subtract‑Method Band Splitting

Step 1: Create total low‑pass (LP) at high crossover: LP_Total = Filter(pass Hann band): 0, High_Split_Hz, 20 Step 2: Create low band at low crossover: Low = Filter(pass Hann band): 0, Low_Split_Hz, 20 Step 3: Create mid band by subtraction: Mid = LP_Total − Low # Contains f_L to f_H Step 4: Create high band by subtraction: High = Original − LP_Total # Contains > f_H Mathematical properties: • Perfect reconstruction: Low + Mid + High = Original • Linear phase characteristics (Hann filter) • 20 Hz transition width smooths crossover • Minimal phase cancellation when recombined Filter characteristics: • Hann‑band filter: smooth frequency response • Transition bandwidth = 20 Hz • Linear phase minimizes time‑domain smearing

Why subtractive method? This approach ensures that bands sum perfectly to the original when no distortion is applied. Traditional parallel filter banks can have phase misalignment at crossover points. The subtractive method uses the same filtered signal (LP_Total) for both mid and high calculations, ensuring phase coherence.

Parameter Interactions

Crossover Frequencies

Low_Split_Hz: Separates sub‑bass from midrange. Typical: 80‑300 Hz.

High_Split_Hz: Separates midrange from highs. Typical: 1500‑5000 Hz.

Interaction: Wider mid band = more fundamental frequencies affected. Narrower bands = more precise spectral control.

Drive (Pre‑Distortion Gain)

Effect: Amplifies signal before distortion nonlinearity.

Per‑band strategy: Higher on mids for presence, lower on highs to avoid harshness, moderate on lows for warmth.

Typical range: 0.5‑5.0 for subtle, 5‑15 for moderate, 15‑30 for extreme.

Distortion Type Selection

Soft Clip: Smooth, musical, analog‑like. Good for most applications.

Hard Clip: Aggressive, digital, rich in odd harmonics. Use for extreme effects.

Sine Fold: Complex, metallic, inharmonic. Experimental textures.

Gain (Post‑Distortion)

Effect: Adjusts level after distortion.

Purpose: Compensate for level loss from distortion, or create spectral balance.

Strategy: Often > 1.0 to restore peaks reduced by clipping.

Spectral Balance Strategies

🎚️ Common Multiband Recipes

Bass‑Focused (Electronic): • Low: Soft Clip @ 3‑5x, Gain 1.1‑1.3 • Mid: Soft Clip @ 1‑2x, Gain 0.9‑1.0 • High: Soft Clip @ 0.5‑1x, Gain 0.8‑0.9 • Result: Warm low‑end, clean mids/highs

Vocal‑Focused: • Low: Soft Clip @ 1x, Gain 0.8 • Mid: Soft Clip @ 2‑4x, Gain 1.1‑1.3 • High: Soft Clip @ 1‑2x, Gain 1.0 • Crossovers: 120 Hz, 4000 Hz • Result: Present vocals, controlled low/high

Guitar "Amp‑Like": • Low: Hard Clip @ 2‑3x, Gain 1.0 • Mid: Soft Clip @ 4‑6x, Gain 1.2 • High: Hard Clip @ 3‑5x, Gain 0.9 • Crossovers: 150 Hz, 3500 Hz • Result: Punchy lows, singing mids, crisp highs

Experimental Texture: • Low: Sine Fold @ 8‑12x, Gain 0.7 • Mid: Hard Clip @ 10‑15x, Gain 0.8 • High: Sine Fold @ 15‑20x, Gain 0.6 • Result: Complex, inharmonic, evolving texture

Parameters & Presets

Common Parameters

ParameterTypeDefaultDescription
PresetoptionmenuManual5 built‑in presets or manual control
Low_Split_Hzreal200Low‑mid crossover frequency
High_Split_Hzreal2500Mid‑high crossover frequency
Low_Drive / Mid_Drive / High_Drivereal1.0Pre‑distortion gain per band
Low_Type / Mid_Type / High_TypeoptionmenuSoft ClipDistortion type per band
Low_Gain / Mid_Gain / High_Gainreal1.0Post‑distortion gain per band
Mix_0_to_1real1.0Wet/dry mix (0=dry, 1=wet)
Output_Gainreal0.9Master output gain
Draw_visualizationboolean1 (yes)Show spectral analysis display
Play_resultboolean1 (yes)Auto‑play after processing

Built‑in Presets

PresetLowMidHighCrossoversCharacter
Warm Bass / Clean HighsSoft @ 3xSoft @ 1xSoft @ 0.5x200/2500Warm low‑end, clean mids/highs
Frizz (Distorted Highs)Soft @ 1xSoft @ 1xHard @ 8x200/1500Clean low/mid, sizzling highs
V‑Shape DestructionHard @ 4xSoft @ 0.5xHard @ 4x200/2500Aggressive lows/highs, clean mids
Mid‑Range CrunchSoft @ 0.5xFold @ 6xSoft @ 0.5x400/3000Telephone‑like mid focus
Full Spectrum FuzzHard @ 5xHard @ 5xHard @ 5x200/2500Heavy distortion across spectrum

Preset Design Philosophy

🎛️ Preset Characteristics Explained

Warm Bass / Clean Highs: • Low band: Moderate Soft Clip (3x) for warmth • Mid band: Unity processing (1x) for transparency • High band: Reduced Drive (0.5x) to avoid harshness • Crossovers: Standard 200/2500 Hz • Use: Bass‑heavy music, electronic, hip‑hop

Frizz (Distorted Highs Only): • Low/Mid: Clean (1x Soft Clip) • High: Extreme Hard Clip (8x) for sizzle • High crossover lowered to 1500 Hz to capture more high‑mids • Use: Guitar "presence" boost, cymbal enhancement, vocal air

V‑Shape Destruction: • Low/High: Aggressive Hard Clip (4x) • Mid: Clean (0.5x Soft Clip) with reduced gain • Creates scooped‑mid "smiley face" EQ with distortion • Use: Aggressive rock/metal, sound design

Mid‑Range Crunch (Telephone): • Low/High: Clean with reduced gain • Mid: Heavy Sine Fold (6x) for complex crunch • Crossovers widened: 400/3000 Hz to focus on vocal range • Use: Lo‑fi effects, vocal processing, retro sounds

Full Spectrum Fuzz: • All bands: Heavy Hard Clip (5x) • Uniform processing across spectrum • Creates traditional "full‑range" fuzz • Use: Extreme distortion, noise music, sound design

Parameter Relationships

Crossover placement: Set Low_Split below fundamental frequencies of bass instruments (typically 80‑200 Hz). Set High_Split above vocal/guitar fundamentals but below cymbal/harmonic content (typically 2000‑5000 Hz).
Drive × Type interaction: Hard Clip benefits from moderate Drive (3‑8x) — too high causes excessive flat‑topping. Sine Fold works best with high Drive (6‑15x) to create complex folding. Soft Clip is versatile across Drive range (1‑10x).
Gain compensation: Distortion reduces peak amplitude. Typical post‑gain: Soft Clip: 1.0‑1.3x, Hard Clip: 0.8‑1.2x, Sine Fold: 0.6‑1.0x. Adjust per band to maintain spectral balance.
Mix control: Use < 1.0 for parallel processing — preserves transients and clarity while adding distortion character. Typical mix: 0.3‑0.7 for subtle enhancement, 1.0 for full effect.

Applications

Mastering‑Grade Distortion

Use case: Adding warmth and harmonics to final mixes

Technique: Use Warm Bass preset with subtle settings

Tip: Low Drive 1.5‑2.5, Mid Drive 1.0‑1.5, High Drive 0.5‑1.0, Mix 0.1‑0.3

Advanced: Different settings for different genres: more low distortion for electronic, more mid for rock

Bass & Kick Processing

Use case: Adding warmth and punch to low‑end

Technique: Focus distortion on low band only

Tip: Low_Split 80‑120 Hz, Low Drive 3‑6 (Soft Clip), Mid/High Drive 1.0

Advanced: Parallel process: heavily distort low band, mix 20‑40% with clean

Vocal Enhancement

Use case: Adding presence and "air" to vocals

Technique: Focus on mid‑high bands

Tip: Low_Split 100‑150 Hz (remove rumble), High_Split 3000‑4000 Hz, Mid Drive 2‑4, High Drive 1‑2

Advanced: De‑ess before multiband distortion to prevent sibilance harshness

Guitar Amp Simulation

Use case: Creating complex amp‑like distortion

Technique: Different distortion types per band

Tip: Low: Hard Clip @ 3x, Mid: Soft Clip @ 5x, High: Hard Clip @ 4x

Advanced: Chain with cabinet IR after distortion for authentic amp sound

Sound Design & Experimental

Use case: Creating unique spectral textures

Technique: Extreme parameter combinations

Tip: Sine Fold on mids, Hard Clip on highs, very different crossover points

Advanced: Automate crossover frequencies for evolving spectral effects

Practical Workflow Examples

🎵 Mastering Warmth

Goal: Subtle harmonic enhancement on master bus

Settings:

  • Preset: Warm Bass (modified)
  • Low: Soft @ 2.0x, Gain 1.1
  • Mid: Soft @ 1.5x, Gain 1.05
  • High: Soft @ 1.0x, Gain 1.0
  • Mix: 0.2 (20% wet)
  • Crossovers: 120 Hz, 3500 Hz

Result: Subtle warmth across spectrum, emphasized low‑end, no harshness

🎸 Modern Metal Guitar

Goal: Tight low‑end, singing mids, crisp highs

Settings:

  • Preset: V‑Shape (modified)
  • Low: Hard @ 3.5x, Gain 1.0
  • Mid: Soft @ 4.0x, Gain 1.2
  • High: Hard @ 3.0x, Gain 0.9
  • Mix: 1.0 (100% wet)
  • Crossovers: 150 Hz, 4000 Hz

Result: Punchy rhythm, singing leads, defined high‑end

🔮 Spectral Morphing

Goal: Evolving spectral distortion texture

Settings:

  • Preset: Manual extreme
  • Low: Sine Fold @ 10x, Gain 0.7
  • Mid: Hard Clip @ 8x, Gain 0.8
  • High: Sine Fold @ 12x, Gain 0.6
  • Mix: 0.5
  • Crossovers: 500 Hz, 2000 Hz (narrow mid)

Result: Complex, inharmonic texture with distinct band character

Troubleshooting Common Issues

Problem: Phase cancellation/"hollow" sound
Cause: Crossover filters causing phase issues at band boundaries
Solution: Adjust crossover frequencies, use wider transition (increase from 20 Hz), or reduce Mix
Problem: Muddy/low‑end loss
Cause: Too much distortion on low band, or Low_Split too high
Solution: Reduce Low Drive, lower Low_Split, increase Low Gain, or use Soft Clip instead of Hard Clip
Problem: Harsh/hissy highs
Cause: Too much Drive on high band, or Hard Clip on highs
Solution: Reduce High Drive, use Soft Clip instead, lower High_Split, or reduce Mix
Problem: Weak/no effect
Cause: Drive too low, Mix too low, or Gain compensation too aggressive
Solution: Increase Drive values, increase Mix, adjust Gain per band
Problem: Aliasing/digital artifacts
Cause: Extreme Drive values, especially with Hard Clip or Sine Fold
Solution: Reduce Drive, use Soft Clip, or oversample before processing

Processing Pipeline

🎛️ Multiband Distortion Processing Flow

START: User Selects Sound
  │
  ▼
INPUT VALIDATION
  │  • Check exactly one Sound selected
  │  • Exit with error if not
  │
  ▼
FORM PROCESSING
  │  • Load user parameters from form
  │  • Apply preset overrides if selected
  │  • Preset mapping:
  │     Manual → "Manual"
  │     Warm Bass → "WarmBass"
  │     Frizz → "Frizz"
  │     V‑Shape → "VShape"
  │     Mid Crunch → "MidCrunch"
  │     Full Fuzz → "FullFuzz"
  │
  ▼
SAFETY CHECKS
  │  • Ensure Low_Split < High_Split (swap if needed)
  │  • Convert type numbers to names:
  │     1 → "Soft", 2 → "Hard", 3 → "Fold"
  │
  ▼
SOUND PROPERTIES
  │  • Get duration, sampling frequency
  │  • Write InfoLine with parameter summary
  │
  ▼
PHASE‑COHERENT CROSSOVER SPLIT
  │
  ├── STEP 1: Total Low‑Pass
  │   • Filter original: 0 to High_Split_Hz (Hann band)
  │   • Result: LP_Total_Temp
  │
  ├── STEP 2: Low Band
  │   • Filter original: 0 to Low_Split_Hz (Hann band)
  │   • Result: Low_Band
  │
  ├── STEP 3: Mid Band (Subtractive)
  │   • Copy LP_Total_Temp → Mid_Band
  │   • Formula: Mid = LP_Total − Low_Band
  │   • Contains: Low_Split to High_Split
  │
  └── STEP 4: High Band (Subtractive)
      • Copy original → High_Band
      • Formula: High = Original − LP_Total
      • Contains: Above High_Split
  │
  ▼
CLEANUP TEMP OBJECT
  │  • removeObject: LP_Total_Temp
  │  • Now have: Low_Band, Mid_Band, High_Band
  │
  ▼
APPLY DISTORTION PER BAND
  │
  ├── LOW BAND PROCESSING
  │   • selectObject: Low_Band
  │   • Call @applyDistortion procedure:
  │     Parameters: Low_Drive, Low_Type, Low_Gain
  │   • Distortion applied in‑place
  │
  ├── MID BAND PROCESSING
  │   • selectObject: Mid_Band
  │   • Call @applyDistortion procedure:
  │     Parameters: Mid_Drive, Mid_Type, Mid_Gain
  │
  └── HIGH BAND PROCESSING
      • selectObject: High_Band
      • Call @applyDistortion procedure:
        Parameters: High_Drive, High_Type, High_Gain
  │
  ▼
DISTORTION PROCEDURE LOGIC (@applyDistortion)
  │  • Convert parameters to strings
  │  • Type 1 (Soft Clip):
  │     Formula: "tanh(self * " + drive$ + ") * " + gain$
  │  • Type 2 (Hard Clip):
  │     Build conditional formula with nested if/then
  │  • Type 3 (Sine Fold):
  │     Formula: "sin(self * " + drive$ + ") * " + gain$
  │
  ▼
SUMMING BANDS (Wet Signal)
  │  • Copy Low_Band → Wet_Sum_Temp
  │  • Formula: Wet = Low + Mid + High
  │  • Apply Output_Gain: Wet = Wet × Output_Gain
  │
  ▼
MIX PROCESSING
  │
  ├── CASE 1: Mix = 1.0 (100% Wet)
  │   • Rename Wet_Sum_Temp → originalname_MultiDist_presetname
  │   • Result = wet signal only
  │   • Cleanup: (no dry object to remove)
  │
  └── CASE 2: Mix < 1.0 (Partial Mix)
      • Copy original → Dry_Temp
      • dry_Mix = 1.0 − mix_0_to_1
      • wet_Mix = mix_0_to_1
      • Formula: Dry = Dry×dry_Mix + Wet×wet_Mix
      • Rename Dry_Temp → originalname_MultiDist_presetname
      • Result = mixed signal
      • Cleanup: removeObject: Wet_Sum_Temp
  │
  ▼
FINAL OUTPUT PROCESSING
  │  • Scale peak to 0.95 (prevent clipping)
  │  • Write completion InfoLine
  │
  ▼
VISUALIZATION PIPELINE (if enabled)
  │
  ├── TITLE PANEL
  │   • "Multiband Distortion: name (preset)"
  │
  ├── ORIGINAL WAVEFORM
  │   • Gray curve
  │   • Time domain view
  │
  ├── PROCESSED WAVEFORM
  │   • Red curve
  │   • Time comparison
  │
  ├── SPECTRAL ANALYSIS
  │   • Convert original to spectrum
  │   • Convert result to spectrum
  │   • Color‑coded band regions:
  │     Low: Pink (0.9, 0.85, 0.85)
  │     Mid: Green (0.85, 0.9, 0.85)
  │     High: Blue (0.85, 0.85, 0.9)
  │   • Draw crossover lines
  │   • Band labels at top
  │
  ├── BAND SETTINGS DISPLAY
  │   • Three‑column layout
  │   • Per‑band: Type, Drive, Gain
  │   • Color‑matched to spectral regions
  │
  └── MASTER INFO
      • Mix percentage
      • Output Gain value
  │
  ▼
VISUALIZATION CLEANUP
  │  • removeObject: temporary spectrum objects
  │  • Reset viewport settings
  │
  ▼
FINALIZATION
  │  • Play result if Play_result enabled
  │  • Keep processed sound selected
  │  • Return to Praat Objects window
  │
END: Multiband‑distorted sound ready for use

Subtractive Crossover Implementation

Phase‑Coherent Band Splitting: Given: Original signal S, crossover frequencies f_L, f_H 1. Low‑pass at high crossover: LP_H = Filter(S, 0, f_H) # Hann band filter 2. Low‑pass at low crossover: LP_L = Filter(S, 0, f_L) 3. Band definitions: Low = LP_L Mid = LP_H − LP_L High = S − LP_H Mathematical properties: Low + Mid + High = LP_L + (LP_H − LP_L) + (S − LP_H) = S Perfect reconstruction when no distortion applied. Filter characteristics: • Type: Hann‑band (smooth frequency response) • Transition width: 20 Hz (default Praat setting) • Linear phase minimizes time‑domain smearing • Gentle roll‑off reduces ringing artifacts

Distortion Procedure Implementation

⚙️ @applyDistortion Procedure

procedure applyDistortion: .drive, .type, .gain # Convert to strings for formula .d$ = string$(.drive) .g$ = string$(.gain) .ng$ = string$(-.gain) # For hard clip negative side if .type = 1 # Soft Clip (Tanh) Formula: "tanh(self * " + .d$ + ") * " + .g$ elsif .type = 2 # Hard Clip - nested if/then (Praat Formula limitation) .input$ = "(self * " + .d$ + ")" Formula: "if " + .input$ + " > 1 then " + .g$ + " else (if " + .input$ + " < -1 then " + .ng$ + " else " + .input$ + " * " + .g$ + " fi) fi" elsif .type = 3 # Sine Fold Formula: "sin(self * " + .d$ + ") * " + .g$ endif endproc

Key implementation details: • String concatenation builds dynamic formulas • Hard Clip requires nested if/then (Praat Formula limitation) • Negative gain string needed for hard clip negative side • Procedure allows reuse for all three bands • In‑place processing (modifies the selected sound object)

Mix Processing Algorithm

Wet/Dry Mix Logic:

Case 1: Mix = 1.0 (100% Wet): • Result = Wet signal only • Rename Wet_Sum_Temp to final name • No dry processing needed

Case 2: Mix < 1.0 (Partial Mix): • dry_Mix = 1.0 − mix_0_to_1 • wet_Mix = mix_0_to_1 • Create dry copy of original • Apply: Dry = Dry×dry_Mix + Wet×wet_Mix • Clean up Wet_Sum_Temp

Mathematical: Output = Dry×(1−α) + Wet×α, where α = mix_0_to_1 Parallel processing benefit: • Preserves transients from dry signal • Adds distortion character from wet • Can use more extreme distortion settings • Typical mix: 0.3‑0.7 for best results

Visualization Architecture

Color‑Coded Spectral Display: • Low band region: Pink background (0.9, 0.85, 0.85) • Mid band region: Green background (0.85, 0.9, 0.85) • High band region: Blue background (0.85, 0.85, 0.9) • Original spectrum: Gray line • Processed spectrum: Red line (0.8, 0.3, 0.3) • Crossover lines: Dark gray at Low_Split and High_Split
Band Settings Display: • Three‑column layout representing Low/Mid/High • Each column color‑matched to spectral region • Shows: Band name, frequency range, distortion type, drive, gain • Uses Paint rectangle for colored backgrounds • Text centered in each column
Performance Considerations: • Crossover filtering: O(n) per filter (three filters total) • Distortion application: O(n) per band • Memory: Creates 4‑5 temporary copies during processing • Visualization: Additional spectrum objects (cleaned up)
Quality vs. Speed Trade‑offs: • Hann‑band filters: High quality, linear phase, but computational • Could use simpler filters for speed (but phase issues) • Current implementation prioritizes phase coherence • Suitable for offline processing, not real‑time

Mathematical Deep Dive

Filter‑Based Crossover Analysis

Hann‑band filter frequency response: Given cutoff frequency f_c and transition bandwidth Δf: H(f) = 0.5 × [1 − cos(π × (f − (f_c − Δf/2)) / Δf)] for f_c − Δf/2 ≤ f ≤ f_c + Δf/2 For low‑pass at f_H: H_LP(f) = 1 for f < f_H − Δf/2 0.5[1−cos(π(f−(f_H−Δf/2))/Δf)] for transition 0 for f > f_H + Δf/2 Phase response: • Linear phase in passband and stopband • Smooth transition in transition band • Minimal group delay variation Perfect reconstruction condition: H_L(f) + [H_H(f) − H_L(f)] + [1 − H_H(f)] = 1 Where H_L = low‑pass at f_L, H_H = low‑pass at f_H This holds for any linear‑phase filter pair.

Distortion Algorithms in Frequency Domain

For sinusoidal input A sin(ωt):

Soft Clip (tanh): y(t) = tanh(D A sin(ωt)) × G Taylor expansion: tanh(z) ≈ z − z³/3 + 2z⁵/15 − ... Thus harmonics at nω with amplitudes: a_n ∝ (D A)^n for odd n, 0 for even n (Due to tanh being odd function) Hard Clip: y(t) = clip(D A sin(ωt)) × G Fourier series of clipped sine: Contains odd harmonics only Amplitude: a_n = (4/π) [sin(nθ)/n − cos(nθ)sin(θ)/(n²−1)] where θ = arcsin(1/(D A)) Sine Fold: y(t) = sin(D A sin(ωt)) × G Using Jacobi‑Anger expansion: sin(z sinθ) = 2 Σ J_{2k+1}(z) sin((2k+1)θ) Contains odd harmonics with Bessel function amplitudes: a_n = 2 J_n(D A) for odd n, 0 for even n

Multiband Harmonic Interaction

When bands are recombined after distortion: Let bands be: L(f), M(f), H(f) after distortion Output spectrum: Y(f) = L(f) + M(f) + H(f) Intermodulation products: • Distortion creates harmonics within each band • No intermodulation between bands (processed separately) • However, phase relationships between bands affect time‑domain sum Phase considerations: • Original phase relationships between frequency components lost • Each band processed independently • Reconstruction sum creates new phase relationships Spectral leakage: • Filter transition bands cause some frequency overlap • Components near crossover appear in both bands • Distorted twice → potentially more intense effect This can be desirable (smooth transition) or problematic (doubling effect). 20 Hz transition width minimizes this.