Asymmetric Soft Clipping — User Guide
Tube-style asymmetric distortion using hyperbolic tangent (tanh) with independent positive/negative shaping, bias control, and visual transfer function display.
What this does
This script implements asymmetric soft clipping — a tube/tape-style distortion effect using a hyperbolic tangent (tanh) transfer function with independent shaping for positive and negative halves of the waveform. Key features: (1) Drive: Pre‑gain before clipping. (2) Bias: DC offset pushing signal into different regions of the tanh curve. (3) Positive/Negative Shape: Separate coefficients for upper/lower halves, creating asymmetric distortion. (4) Output Gain: Post‑clipping volume adjustment. (5) 5 Built‑in Presets: From subtle warmth to hard fuzz. (6) Visualization: Displays original vs. distorted waveform and the transfer function (input‑output curve).
Key Features:
- Asymmetric Shaping — Independent positive/negative curve coefficients
- Bias Control — DC offset for gating/broken‑tube effects
- 5 Built‑in Presets — Warm Tube, Hard Overdrive, Asymmetric Fuzz, Broken Bias, Subtle Warmer
- Visual Transfer Function — Draws input‑output curve for parameter insight
- Waveform Comparison — Side‑by‑side original vs. distorted display
- Real‑time Formula Generation — Dynamic tanh expression based on parameters
Technical Implementation: (1) Signal path: Input × Drive + Bias → conditional shape selection (positive vs. negative) → tanh(…) × Output Gain. (2) Formula generation: The script constructs a string formula dynamically: tanh((self*drive + bias) * ((in>=0)*pos_Shape + (in<0)*neg_Shape)) * output_Gain. (3) Visualization: Three‑panel display: original waveform, distorted waveform, and transfer function (input‑output mapping from −1.5 to +1.5). (4) Processing: Applied sample‑by‑sample via Praat’s Formula command. (5) Presets: Override manual sliders with curated settings for common distortion characters.
Quick start
- In Praat, select exactly one Sound object.
- Run script… →
apply_asymmetric_clipping.praat. - Choose a Preset (overrides sliders) or "Manual" to use sliders.
- Adjust Drive (pre‑gain), Bias (DC offset), Pos_Shape/Neg_Shape (asymmetry), Output_Gain (volume).
- Enable Draw_visualization to see waveforms and transfer curve.
- Enable Play_result to audition after processing.
- Click OK — effect applied, result named "originalname_Tube_presetname".
Distortion Theory
Hyperbolic Tangent (tanh) as Soft Clipper
Mathematical Form
Why tanh?
Advantages over hard clipping or polynomials:
- Smooth saturation: No discontinuities → fewer aliasing artifacts
- Natural sounding: Matches vacuum‑tube/tape saturation characteristics
- Computationally simple: Built‑in function in Praat
- Musical harmonics: Produces harmonic series that decays smoothly
Parameter Roles
Drive (Pre‑Gain)
Effect: Multiplies input before clipping. Higher Drive pushes more signal into nonlinear region.
Range: 1.0 (no gain) to 10+ (heavy saturation).
Audible result: Increases distortion intensity, adds harmonics, reduces dynamic range.
Bias (DC Offset)
Effect: Adds constant offset, shifting operating point on tanh curve.
Range: −1.0 to +1.0 (typical). Positive bias pushes signal toward positive saturation.
Audible result: Can create gating/starved‑tube effects; changes symmetry of distortion.
Pos_Shape / Neg_Shape (Asymmetry)
Effect: Different coefficients for positive/negative halves.
Range: 0.1 (gentle curve) to 5.0 (hard clipping).
Audible result: Pos_Shape > Neg_Shape: positive peaks clip more → even‑order harmonics ("warm"). Equal values: symmetric odd‑order harmonics ("metallic").
Output_Gain (Volume Compensation)
Effect: Multiplies after clipping to adjust overall level.
Range: 0.0 to 2.0 (typical).
Audible result: Restores loudness lost to clipping; can be used for boost/cut.
Transfer Function Visualization
Axes: X = input amplitude (−1.5 to +1.5), Y = output amplitude
Diagonal gray line: Linear transfer (no distortion, y = x)
Colored curve: Actual input‑output mapping
Shape interpretation:
• Steep slope near zero = high gain
• Flat regions = saturation (clipping)
• Asymmetry around zero = different positive/negative behavior
• Bias shifts curve left/right
• Drive stretches input horizontally
Harmonic Generation
How distortion creates harmonics:
Preset Designs
🎸 Preset Characteristics
Warm Tube Saturation: Low drive, small bias, slight asymmetry → gentle even harmonics, "analog warmth."
Hard Overdrive: High drive, no bias, symmetric shaping → aggressive odd harmonics, "amp‑like crunch."
Asymmetric Fuzz: Medium drive, positive bias, strong asymmetry → splattery, gated fuzz with rich even harmonics.
Broken/Gated Bias: High bias pushes quiet signals into flat region → silence below threshold, "dying battery" effect.
Subtle Warmer: Minimal drive, tiny bias, near‑linear → just a hint of saturation, "mastering‑style enhancement."
Parameters & Presets
Common Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Preset | optionmenu | Manual | 5 built‑in presets or manual control |
| Drive | real | 2.0 | Pre‑clipping gain (1.0 = no gain) |
| Bias | real | 0.1 | DC offset (−1.0 to +1.0) |
| Pos_Shape | real | 1.0 | Positive‑half shaping coefficient |
| Neg_Shape | real | 3.0 | Negative‑half shaping coefficient |
| Output_Gain | real | 0.8 | Post‑clipping volume (0.0‑2.0) |
| Draw_visualization | boolean | 1 (yes) | Show waveforms & transfer curve |
| Play_result | boolean | 1 (yes) | Auto‑play after processing |
Built‑in Presets
| Preset | Drive | Bias | Pos_Shape | Neg_Shape | Output_Gain | Character |
|---|---|---|---|---|---|---|
| Warm Tube Saturation | 1.5 | 0.05 | 0.8 | 1.2 | 0.9 | Gentle even harmonics, analog warmth |
| Hard Overdrive | 5.0 | 0.0 | 2.0 | 2.0 | 0.5 | Aggressive symmetric crunch |
| Asymmetric Fuzz | 3.5 | 0.3 | 5.0 | 0.5 | 0.6 | Splattery, gated, rich even harmonics |
| Broken/Gated Bias | 4.0 | 0.8 | 4.0 | 0.5 | 0.6 | Quiet passages silent, "dying battery" |
| Subtle Warmer | 1.1 | 0.02 | 0.5 | 0.6 | 0.95 | Just‑noticeable saturation, mastering‑style |
Parameter Interaction Tips
Applications
Guitar/Bass Overdrive
Use case: Amp‑like distortion for electric instruments
Technique: Use Warm Tube Saturation or Hard Overdrive presets
Tip: Adjust Drive to match playing dynamics; add Bias for "starved‑tube" character
Vocal Warmth/Saturation
Use case: Adding harmonic richness to vocals
Technique: Subtle Warmer preset, very low Drive (1.1‑1.3), slight asymmetry
Tip: Use high‑pass filter before clipping to avoid low‑end mud
Synth & Drum Processing
Use case: Aggressive sound design for electronic music
Technique: Asymmetric Fuzz or Broken Bias presets
Tip: Process drum buses for "crunchy" texture; use Bias to gate quieter hits
Lo‑Fi & Degradation Effects
Use case: Emulating tape saturation, cassette wow‑and‑flutter
Technique: Moderate Drive (2‑3), positive Bias (0.1‑0.3), asymmetric shaping
Tip: Add slight noise after clipping for authentic lo‑fi character
Creative Sound Design
Use case: Extreme distortion for experimental textures
Technique: High Drive (>5), extreme asymmetry (e.g., Pos_Shape=10, Neg_Shape=0.2)
Tip: Visualize transfer curve to understand shaping
Practical Workflow Examples
🎸 Guitar Rhythm Track
Goal: Classic rock overdrive
Settings:
- Preset: Warm Tube Saturation
- Drive: 1.8 (adjust to playing)
- Bias: 0.1
- Pos_Shape: 1.0, Neg_Shape: 1.5
- Output_Gain: 0.9
Result: Warm, dynamic overdrive with singing sustain
🎙️ Vocal Thickening
Goal: Subtle harmonic enhancement
Settings:
- Preset: Subtle Warmer
- Drive: 1.2
- Bias: 0.0
- Pos_Shape: 0.7, Neg_Shape: 0.9
- Output_Gain: 0.95
Result: Vocal sounds "larger" without obvious distortion
⚡ Glitch/Noise Effects
Goal: Broken, gated distortion
Settings:
- Preset: Broken/Gated Bias
- Drive: 4.5
- Bias: 0.7
- Pos_Shape: 3.0, Neg_Shape: 0.3
- Output_Gain: 0.7
Result: Quiet passages disappear, loud parts explode with splattery distortion
Troubleshooting Common Issues
Cause: Clipping reduces peak amplitude; Output_Gain too low
Solution: Increase Output_Gain (0.8‑1.2 typical), or normalize after processing
Cause: Symmetric shaping (Pos_Shape ≈ Neg_Shape) producing odd harmonics
Solution: Increase asymmetry (e.g., Pos_Shape=1.0, Neg_Shape=2.0)
Cause: High Bias pushes signal into flat region of tanh
Solution: Reduce Bias to 0.0‑0.2, or increase Drive
Cause: Drive too high, or shaping coefficients extreme
Solution: Reduce Drive (1.5‑3.0 for moderate), keep Pos_Shape/Neg_Shape between 0.5‑3.0
Processing Pipeline
🔄 Asymmetric Soft Clipping 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
│ • Convert preset names (spaces removed)
│
▼
PRESET HANDLING
│
├── Manual ────────────┐
│ • Use form values │
│ │
├── Warm Tube ────────┤
│ • Drive = 1.5 │
│ • Bias = 0.05 │
│ • Pos = 0.8 │
│ • Neg = 1.2 │
│ • Gain = 0.9 │
│ │
├── Hard Overdrive ───┤
│ • Drive = 5.0 │
│ • Bias = 0.0 │
│ • Pos = 2.0 │
│ • Neg = 2.0 │
│ • Gain = 0.5 │
│ │
├── Asymmetric Fuzz ──┤
│ • Drive = 3.5 │
│ • Bias = 0.3 │
│ • Pos = 5.0 │
│ • Neg = 0.5 │
│ • Gain = 0.6 │
│ │
├── Broken Bias ──────┤
│ • Drive = 4.0 │
│ • Bias = 0.8 │
│ • Pos = 4.0 │
│ • Neg = 0.5 │
│ • Gain = 0.6 │
│ │
└── Subtle Warmer ────┘
• Drive = 1.1
• Bias = 0.02
• Pos = 0.5
• Neg = 0.6
• Gain = 0.95
│
▼
SOUND PREPARATION
│ • Get original sound properties
│ • Create copy: originalname_Tube_presetname
│ • Select copy for processing
│
▼
FORMULA GENERATION ENGINE
│ • Convert parameters to strings
│ • Build input expression: (self * drive + bias)
│ • Build shape logic: ((in>=0)*pos + (in<0)*neg)
│ • Combine: tanh(input * shape) * output_gain
│ • Construct final formula string
│
▼
CORE PROCESSING
│ • Apply formula via Praat's Formula command
│ • Sample-by-sample processing:
│ 1. Scale by Drive, add Bias
│ 2. Select shape based on sign
│ 3. Apply tanh nonlinearity
│ 4. Scale by Output_Gain
│
▼
VISUALIZATION PIPELINE
│
├── TITLE PANEL
│ • Display effect name and source
│
├── ORIGINAL WAVEFORM
│ • Gray curve
│ • Time axis 0‑duration
│
├── DISTORTED WAVEFORM
│ • Red curve (0.8, 0.4, 0.4)
│ • Time axis with labels
│
├── TRANSFER FUNCTION
│ • Input range: -1.5 to 1.5
│ • Calculate curve points
│ • Draw colored transfer curve
│ • Add threshold/grid lines
│
└── PARAMETER DISPLAY
• Preset name
• Parameter values
• Drive, Bias, Shape, Gain
│
▼
TRANSFER FUNCTION CALCULATION
│ • For 100 points from -1.5 to 1.5:
│ 1. val_in = x * drive + bias
│ 2. shape = pos if val_in>=0 else neg
│ 3. y = tanh(val_in * shape) * output_gain
│ 4. Draw line segments
│
▼
OUTPUT FINALIZATION
│ • Play result if enabled
│ • Write InfoLine summary
│ • Keep processed sound selected
│
▼
CLEANUP
│ • (No temporary objects to clean)
│ • Return to Praat Objects window
│
END: Processed sound ready for use
Formula Generation Details
Visualization Architecture
📊 Multi‑Panel Display System
Viewport Management: • Panel 1: 0,8 × 0.1,0.5 → Title • Panel 2: 0,8 × 0.6,1.6 → Original waveform • Panel 3: 0,8 × 1.7,2.7 → Distorted waveform • Panel 4: 0,8 × 2.9,5.0 → Transfer function • Panel 5: 0,8 × 5.1,5.5 → Parameter display
Color Scheme: • Original: Gray {0.6, 0.6, 0.6} • Distorted: Red {0.8, 0.4, 0.4} • Transfer: Green {0.2, 0.5, 0.2} • Grid: Light gray {0.8, 0.8, 0.8} • Text: Black
Curve Plotting: • 100‑point resolution • Line width: 2.5 for transfer function • Previous/current point connection • Anti‑aliased drawing
Performance Characteristics
Mathematical Deep Dive
Hyperbolic Tangent Properties
Harmonic Analysis of Asymmetric tanh
For a sine wave input A sin(ωt):