Dynamic Distortion — User Guide
Envelope‑following distortion: drive amount changes with signal amplitude for expressive, touch‑responsive saturation effects.
What this does
This script implements dynamic distortion — a responsive saturation effect where the amount of distortion (drive) varies with the input signal's amplitude. An envelope follower tracks the audio level, and this envelope controls the distortion intensity. Key features: (1) Envelope‑following drive: Drive = Base_Drive + (Envelope × Sensitivity). (2) Adjustable response: Control envelope follower speed (Response_Speed_Hz). (3) 4 Built‑in Presets: Touch‑sensitive, Drum pumping, Gated crunch, Expressive lead. (4) Comprehensive visualization: Shows original, distorted, envelope, computed drive, and transfer functions. (5) Stereo‑container processing: Efficient single‑pass algorithm using multichannel trickery.
Key Features:
- Amplitude‑responsive distortion — louder = more saturation
- Envelope follower with adjustable speed — from 1 Hz (slow) to 100 Hz (fast)
- 4 Built‑in Presets — Optimized for different musical contexts
- Negative Base_Drive capability — Creates gating/expanding effects
- Multipanel visualization — 5 simultaneous displays for parameter insight
- Efficient stereo‑container algorithm — Processes audio and envelope in single pass
Technical Implementation: (1) Envelope extraction: Convert to mono → absolute value → low‑pass filter (Response_Speed_Hz) → smoothed envelope. (2) Stereo container creation: Combine original audio (channel 1) and envelope (channel 2) into single stereo object. (3) Dynamic distortion formula: For each sample: Drive = Base_Drive + (envelope_sample × Sensitivity), Output = tanh(audio_sample × Drive) × Output_Gain. (4) Efficient processing: Uses Praat's Formula with row/col indexing to process both channels simultaneously. (5) Visualization: Five‑panel display showing: original waveform, distorted result, envelope signal, computed drive over time, and transfer function comparison (low vs high drive).
Quick start
- In Praat, select exactly one Sound object.
- Run script… →
apply_dynamic_distortion.praat. - Choose a Preset (overrides sliders) or "Manual" to use sliders.
- Adjust Base_Drive (minimum distortion when quiet).
- Set Sensitivity (how much envelope adds to drive).
- Choose Response_Speed_Hz (envelope follower speed).
- Set Output_Gain for volume compensation.
- Enable Draw_visualization to see all analysis panels.
- Click OK — effect applied, result named "originalname_DynDist_presetname".
Dynamic Distortion Theory
Core Algorithm
📈 Envelope‑Following Distortion Pipeline
Key insight: The envelope env(t) tracks the audio's amplitude. This envelope then modulates the distortion amount in real time. When audio is loud (env(t) large), drive(t) increases → more distortion. When audio is quiet (env(t) small), drive(t) approaches Base_Drive → less distortion.
Envelope Follower Design
Rectification + Low‑Pass Filter
Response Speed Interpretation
1‑5 Hz: Very slow, "laggy" envelope • Good for: Slow volume swells, ambient textures • Sounds like: Compression with slow attack/release
10‑30 Hz: Musical, natural tracking • Good for: Most instruments, vocals, guitar • Sounds like: Tube‑amp‑like responsiveness
40‑80 Hz: Fast, aggressive tracking • Good for: Drums, percussion, transient‑rich material • Sounds like: Aggressive pumping, "breathing" effects
100+ Hz: Very fast, may track individual cycles • Good for: Extreme effects, ring‑mod‑like sounds • Sounds like: Waveform‑cycle distortion modulation
Drive Computation
Base_Drive (Minimum Distortion)
Effect: Drive value when envelope = 0 (silent portions).
Typical range: 0.5‑2.0 for normal use; negative values for gating.
Behavior: • Base_Drive > 0: Always some distortion, even during silence • Base_Drive = 0: No distortion when silent • Base_Drive < 0: Negative drive until envelope overcomes it → gating effect
Sensitivity (Envelope→Drive Scaling)
Effect: How much the envelope increases distortion.
Typical range: 2‑10 (higher = more responsive).
Mathematical: ΔDrive = Sensitivity × Envelope. If envelope ranges 0‑0.5 and Sensitivity=6, drive increases by 0‑3.0.
Total Drive Range
Formula: Drive_min = Base_Drive (when envelope=0)
Formula: Drive_max = Base_Drive + Sensitivity × Envelope_max
Example: Base_Drive=1.0, Sensitivity=5, Envelope_max=0.4 → Drive ranges 1.0‑3.0
Audible effect: Wide range = dramatic distortion changes; narrow range = subtle modulation.
Stereo‑Container Processing Trick
Visualization System
Panel 1 (Original): Gray waveform — input signal
Panel 2 (Result): Red waveform — distorted output
Panel 3 (Envelope): Green curve — extracted amplitude envelope
Panel 4 (Drive): Brown curve — computed drive over time (Base_Drive + Sensitivity×Envelope)
Panel 5 (Transfer): Gray/red curves — tanh transfer functions for low/high drive
Interpretation: Watch how envelope (Panel 3) tracks audio peaks. See how drive (Panel 4) follows envelope. Note transfer function changes in Panel 5 — gray curve = low drive (quiet), red curve = high drive (loud).
Parameters & Presets
Common Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Preset | optionmenu | Manual | 4 built‑in presets or manual control |
| Base_Drive | real | 1.0 | Minimum drive when quiet |
| Sensitivity | real | 5.0 | How much envelope adds to drive |
| Response_Speed_Hz | real | 20.0 | Envelope follower speed (Hz) |
| Output_Gain | real | 0.9 | Post‑distortion volume |
| Draw_visualization | boolean | 1 (yes) | Show 5‑panel analysis display |
| Play_result | boolean | 1 (yes) | Auto‑play after processing |
Built‑in Presets
| Preset | Base_Drive | Sensitivity | Response_Speed | Output_Gain | Character |
|---|---|---|---|---|---|
| Touch Sensitive Drive | 0.8 | 3.0 | 15 Hz | 0.9 | Expressive, guitar‑amp‑like responsiveness |
| Drum Pumper | 1.0 | 8.0 | 50 Hz | 0.8 | Aggressive, transient‑heavy drum compression |
| Gated Crunch | -0.5 | 10.0 | 80 Hz | 1.0 | Silence between hits, explosive on transients |
| Expressive Lead | 1.2 | 4.0 | 10 Hz | 0.9 | Smooth, legato‑friendly envelope tracking |
Parameter Interaction Guide
Preset Design Philosophy
🎸 Preset Characteristics Explained
Touch Sensitive Drive: • Moderate Base_Drive (0.8) = light always‑on saturation • Low Sensitivity (3.0) = subtle dynamic response • Medium Response (15 Hz) = natural envelope tracking • Ideal for: Guitar solos, expressive vocals
Drum Pumper: • Higher Base_Drive (1.0) = noticeable saturation • High Sensitivity (8.0) = dramatic dynamic changes • Fast Response (50 Hz) = tracks drum transients • Lower Output_Gain (0.8) = compensates for peak saturation
Gated Crunch: • Negative Base_Drive (-0.5) = gating effect • Very High Sensitivity (10.0) = explosive when threshold crossed • Very Fast Response (80 Hz) = instant on transients • Output_Gain=1.0 = preserve dynamics
Expressive Lead: • Higher Base_Drive (1.2) = rich saturation • Moderate Sensitivity (4.0) = controlled dynamics • Slow Response (10 Hz) = smooth envelope, ignores fast variations • Ideal for: Legato synth leads, sustained instruments
Applications
Expressive Guitar/Bass Processing
Use case: Touch‑responsive amp simulation
Technique: Use Touch Sensitive Drive preset
Tip: Adjust Sensitivity to match playing dynamics; lower for subtle, higher for dramatic
Advanced: Chain with static distortion before dynamic stage for complex saturation
Drum Bus Compression‑Distortion
Use case: Aggressive drum bus processing
Technique: Use Drum Pumper preset
Tip: Fast Response_Speed_Hz (40‑60 Hz) tracks transients; high Sensitivity (6‑10) creates pumping
Advanced: Blend dry signal with processed for parallel compression effect
Vocal Saturation with Dynamics
Use case: Natural‑sounding vocal warmth
Technique: Use Expressive Lead preset with slower Response_Speed_Hz (10‑15)
Tip: Low Base_Drive (0.5‑0.8) for subtle saturation; moderate Sensitivity (3‑5) for phrase‑based dynamics
Advanced: Apply to vocal bus rather than individual tracks for cohesion
Gated/Noise‑Gate Distortion Effects
Use case: "Dying battery" or noise‑gate‑into‑distortion effects
Technique: Use Gated Crunch preset or set Base_Drive negative
Tip: Negative Base_Drive = -0.3 to -1.0; high Sensitivity = 8‑12 for explosive bursts
Advanced: Combine with tremolo or autopan for rhythmic gating effects
Synth & Sound Design
Use case: Dynamic textures for electronic music
Technique: Experiment with extreme Response_Speed_Hz (1‑100 Hz)
Tip: Very slow Response (1‑5 Hz) creates evolving saturation over seconds
Advanced: Automate Sensitivity parameter over time for evolving dynamic response
Practical Workflow Examples
🎸 Live Guitar Tone
Goal: Dynamic amp‑like distortion that cleans up with volume knob
Settings:
- Preset: Touch Sensitive Drive (modified)
- Base_Drive: 0.6 (clean headroom)
- Sensitivity: 4.0 (responsive to picking)
- Response_Speed_Hz: 20 Hz (natural tracking)
- Output_Gain: 1.0
Result: Light crunch at normal playing, heavy distortion when digging in
🥁 Drum Room Ambience
Goal: Distort only drum room/ambience, not close mics
Settings:
- Preset: Drum Pumper
- Base_Drive: 0.3 (subtle on quiet ambience)
- Sensitivity: 12.0 (explosive on drum hits)
- Response_Speed_Hz: 60 Hz (fast transient tracking)
- Output_Gain: 0.7 (reduce level)
Result: Room mics "bloom" with saturation on each hit, clean between
🔊 Glitch/Gated Textures
Goal: Broken, intermittent distortion for glitch effects
Settings:
- Preset: Gated Crunch (modified)
- Base_Drive: -0.8 (strong gating)
- Sensitivity: 15.0 (extremely responsive)
- Response_Speed_Hz: 100 Hz (instant response)
- Output_Gain: 1.2 (boost bursts)
Result: Silence punctuated by explosive distortion bursts
Advanced Techniques
Troubleshooting Common Issues
Cause: Response_Speed_Hz too fast, tracking waveform cycles instead of amplitude envelope
Solution: Lower Response_Speed_Hz (10‑30 Hz for most material)
Cause: Response_Speed_Hz too slow, envelope lags behind audio
Solution: Increase Response_Speed_Hz (40‑80 Hz for percussive material)
Cause: Sensitivity too high/low relative to envelope range
Solution: Adjust Sensitivity while watching envelope display (Panel 3). Aim for drive range that sounds musical.
Cause: Base_Drive negative value inappropriate for signal level
Solution:
Cause: Output_Gain inappropriate for amount of saturation
Solution: Adjust Output_Gain (0.7‑1.3 typical). Heavy saturation reduces peaks → may need gain > 1.0.
Mathematical Deep Dive
Envelope Follower Analysis
Dynamic Distortion Harmonic Analysis
For sinusoid with time‑varying drive: