Foldback and Wavefolding — User Guide
Nonlinear distortion through signal folding: creates harmonic complexity by mirroring audio signals beyond threshold boundaries.
What this does
This script implements foldback and wavefolding distortion — a sophisticated nonlinear processing technique that creates harmonic complexity by mirroring audio signals when they exceed defined thresholds. The process: (1) Input gain: Amplify signal to drive into nonlinear region, (2) Threshold detection: Identify signal peaks beyond fold boundaries, (3) Signal folding: Mirror excess signal back toward zero, (4) Iterative processing: Apply multiple folds for complex harmonics, (5) Output conditioning: Apply smoothing, gain staging, and DC removal. Result: rich harmonic distortion that adds complexity and character without traditional clipping artifacts.
Key Features:
- 8 Intelligent Presets — From subtle saturation to extreme distortion
- Vectorized Processing — Efficient sample-by-sample algorithm
- Bipolar/Unipolar Folding — Different harmonic generation methods
- Asymmetric Thresholds — Different positive/negative fold points
- Iterative Folding — Multiple fold stages for complex spectra
- Smoothing Options — Soft clipping to reduce harshness
Technical Implementation: (1) Input conditioning: Apply gain and calculate asymmetric thresholds. (2) Foldback algorithm: Vectorized Formula operations for efficient processing. (3) Bipolar folding: Separate positive/negative threshold handling. (4) Iterative processing: Multiple passes through fold algorithm. (5) Output conditioning: Smoothing, gain compensation, DC removal, peak protection. Key insight: Signal mirroring at thresholds creates harmonically rich distortion different from traditional clipping.
Quick start
- In Praat, select exactly one Sound object.
- Run script… →
foldback_wavefolding.praat. - Choose preset: Soft Fold for subtle effects, Hard Fold for aggressive distortion.
- Adjust input gain to control distortion amount (higher = more folding).
- Modify threshold to set foldback point (lower = earlier folding).
- Click OK — processes audio, creates "originalname_fold" output.
Foldback Distortion Theory
Basic Foldback Mathematics
Core Folding Algorithm
Foldback function definition:
Harmonic Generation
Why folding creates harmonics:
Bipolar vs Unipolar Folding
Symmetric vs Asymmetric Processing
Harmonic characteristics:
Iterative Folding
Multiple Fold Stages
Cascaded folding effects:
Complete Processing Pipeline
Preset Configurations
Preset 1: Custom
⚙️ Full Parameter Control
Threshold: User specified (default: 0.5)
Input Gain: User specified (default: 0.0 dB)
Fold Depth: User specified (default: 1.0)
Character: Fully customizable foldback distortion
Best for: Experimental work, specific harmonic targeting
Preset 2: Soft Fold (Subtle)
🎵 Gentle Harmonic Enhancement
Threshold: 0.7 (high, gentle folding)
Input Gain: 3.0 dB (light drive)
Fold Depth: 0.6 (moderate folding)
Smoothing: 0.3 (smooth character)
Character: Warm, subtle, musical enhancement
Best for: Vocals, acoustic instruments, subtle saturation
Preset 3: Hard Fold (Aggressive)
🔥 Intense Harmonic Distortion
Threshold: 0.3 (low, aggressive folding)
Input Gain: 12.0 dB (heavy drive)
Fold Depth: 1.0 (full folding)
Smoothing: 0.0 (raw, edgy)
Character: Aggressive, bright, intense distortion
Best for: Drums, synths, electric guitars, special FX
Preset 4: Bipolar Fold
⚖️ Symmetric Harmonic Generation
Threshold: 0.5 (balanced)
Input Gain: 6.0 dB (moderate drive)
Fold Iterations: 2 (complex harmonics)
Bipolar: Enabled (symmetric)
Character: Rich, complex, odd-harmonic dominant
Best for: Synthetic sounds, complex textures
Preset 5: Asymmetric Fold
🎛️ Even + Odd Harmonic Mix
Threshold: 0.6 (moderate-high)
Input Gain: 8.0 dB (medium drive)
Asymmetry: 0.6 (strong positive bias)
Bipolar: Disabled (asymmetric processing)
Character: Warm, transformer-like, even harmonics
Best for: Analog simulation, warm distortion
Preset 6: Multi-Fold (Harmonics)
🎶 Complex Harmonic Structures
Threshold: 0.4 (moderate-low)
Input Gain: 10.0 dB (strong drive)
Fold Iterations: 3 (multiple stages)
Fold Depth: 1.0 (full folding)
Character: Very complex, dense harmonic texture
Best for: Experimental sounds, maximal distortion
Preset 7: Tape Saturation Style
📼 Analog Tape Simulation
Threshold: 0.65 (gentle folding)
Input Gain: 4.0 dB (light drive)
Fold Depth: 0.5 (soft folding)
Smoothing: 0.5 (very smooth)
Character: Warm, smooth, vintage tape-like
Best for: Mix bus, vocals, overall warming
Preset 8: Digital Crush
💥 Extreme Digital Distortion
Threshold: 0.25 (very aggressive)
Input Gain: 15.0 dB (extreme drive)
Fold Iterations: 2 (complex)
Bipolar: Disabled (asymmetric)
Character: Harsh, digital, bit-crush style
Best for: Special effects, aggressive textures
Preset 9: Oscillating Fold
🔄 Dynamic Harmonic Movement
Threshold: 0.55 (balanced)
Input Gain: 7.0 dB (medium drive)
Asymmetry: -0.3 (negative bias)
Fold Iterations: 2 (complex)
Character: Dynamic, moving, complex harmonics
Best for: Evolving textures, synthetic sounds
Preset Transfer Function Visualization
Soft Fold: ────╮···╭─── (gentle curves)
Hard Fold: ──┐ │ ┌── (sharp folds)
Bipolar Fold: ──┐ │ ┌── (symmetric)
Asymmetric Fold: ──┐ │ ╰── (uneven sides)
Multi-Fold: ─╮│╭│╮│╭─ (multiple folds)
Tape Style: ───╮···╭─── (smooth saturation)
Digital Crush: ─┐ ┌┐ ┌┐ ┌─ (aggressive folds)
Oscillating: ─╮│╰│╮│╭─ (dynamic asymmetry)
Vertical lines represent fold thresholds
Folding Algorithms
Bipolar Folding Algorithm
⚖️ Symmetric Signal Processing
Principle: Equal treatment of positive and negative signal halves
Implementation: Separate positive and negative threshold checks
Harmonic Result: Odd harmonics dominant, balanced spectrum
Character: Clean, tube-amp like, musical
Bipolar Algorithm Details
Unipolar Folding Algorithm
🎛️ Asymmetric Signal Processing
Principle: Combined positive/negative processing
Implementation: Absolute value threshold checking
Harmonic Result: Mixed even and odd harmonics
Character: Warmer, transformer-like, rich
Unipolar Algorithm Details
Smoothing Algorithm
🔄 Soft Clipping Integration
Principle: Apply soft clipping to fold transitions
Implementation: Conditional soft saturation
Result: Smoother transitions, reduced harshness
Character: More analog-like, less digital
Smoothing Implementation
Vectorized Processing Advantage
⚡ Efficient Sample Processing
Principle: Process all samples simultaneously using Praat's Formula
Implementation: Vectorized conditional operations
Benefit: Much faster than sample-by-sample loop
Trade-off: Different computational characteristics
Vectorized vs Sequential Processing
Parameters & Settings
Core Folding Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Preset | optionmenu | Custom | Predefined folding configurations |
| Threshold_(0-1) | real | 0.5 | Signal level where folding begins |
| Input_gain_(dB) | real | 0.0 | Pre-folding amplification |
| Fold_depth_(0-1) | real | 1.0 | Intensity of folding effect |
| Asymmetry_(-1_to_1) | real | 0.0 | Positive/negative threshold difference |
Advanced Processing Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Fold_iterations | integer | 1 | Number of folding passes |
| Bipolar_folding | boolean | 1 | Separate positive/negative processing |
| Smoothing_(0-1) | real | 0.0 | Soft clipping amount |
| Output_gain_(dB) | real | 0.0 | Post-processing level adjustment |
| DC_offset_removal | boolean | 1 | Remove DC component from output |
Parameter Interactions and Guidelines
Gain Staging Formulas
Applications
Music Production
Use case: Adding harmonic complexity to sounds
Technique: Apply Soft Fold or Tape Style to individual tracks
Example: Vocal harmonic enhancement with Soft Fold preset
Sound Design
Use case: Creating complex textures from simple sources
Technique: Use Multi-Fold or Hard Fold with high iterations
Example: Turning sine waves into rich harmonic stacks
Synthesizer Design
Use case: Wave shaping for complex oscillator spectra
Technique: Apply folding to basic waveforms
Example: Creating complex synth sounds from simple oscillators
Guitar Processing
Use case: Amp simulation and distortion effects
Technique: Use Bipolar Fold for tube-amp character
Example: Guitar distortion with musical harmonic content
Practical Workflow Examples
🎤 Vocal Harmonic Enhancement
Goal: Add warmth and presence to vocal track
Settings:
- Preset: Soft Fold or Tape Style
- Input gain: 3-6 dB
- Threshold: 0.6-0.8
- Smoothing: 0.3-0.5
- Fold iterations: 1
Result: Warmer, more present vocal with subtle harmonics
🥁 Drum Destruction
Goal: Create aggressive, distorted drum sounds
Settings:
- Preset: Hard Fold or Digital Crush
- Input gain: 12-18 dB
- Threshold: 0.2-0.4
- Fold iterations: 2-3
- Smoothing: 0.0-0.2
Result: Powerful, distorted drums with complex harmonics
🎹 Synth Wave Shaping
Goal: Create complex synth textures from simple waves
Settings:
- Preset: Multi-Fold or Bipolar Fold
- Input gain: 8-12 dB
- Threshold: 0.4-0.6
- Fold iterations: 2-3
- Asymmetry: Experiment with values
Result: Rich, complex synth sounds with evolving harmonics
Advanced Techniques
- Progressive folding: Automate threshold over time for evolving effects
- Frequency-specific folding: Apply to filtered frequency bands only
- Parallel processing: Mix heavily folded and dry signals
- Serial processing: Apply multiple fold stages with different settings
- Modulation: Use asymmetry modulation for dynamic harmonic movement
- Electronic music: Use Multi-Fold for complex synth textures
- Rock music: Use Bipolar Fold for guitar amp simulation
- Hip-hop: Use Asymmetric Fold for warm drum processing
- Ambient: Use Soft Fold with smoothing for atmospheric textures
- Experimental: Use extreme settings with high iterations
Troubleshooting Common Issues
Cause: Too high input gain or too low threshold
Solution: Reduce input gain, increase threshold, use fewer iterations
Cause: Lack of smoothing with aggressive settings
Solution: Increase smoothing, reduce fold depth, use bipolar folding
Cause: Insufficient input gain or too high threshold
Solution: Increase input gain, decrease threshold, check fold depth
Cause: Asymmetric processing without DC removal
Solution: Enable DC offset removal, check asymmetry settings
Cause: Extreme folding creating unusual peaks
Solution: Adjust output gain, enable peak protection, use smoothing