Distortion & Bit-Crusher Suite — User Guide

Digital degradation and aggressive transformation: combines bit-depth reduction with zero-crossing distortion, amplitude modulation, and rhythmic gating for industrial-grade audio processing.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 1.0 (2025) License: MIT License Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

What this does

This script implements a dual-mode distortion suite — combining classic bit-crushing degradation with aggressive harsh distortion for extreme audio transformation. Two distinct processing modes: (1) Bit Crusher: Reduces amplitude resolution by quantizing to discrete levels, creating the characteristic "stepped" waveforms of low-bit digital audio. (2) Harsh Distortion: Replaces original waveform with synthesized textures using zero-crossing detection, amplitude modulation, and rhythmic gating. The suite includes 8 carefully designed presets spanning subtle lo-fi degradation to extreme industrial destruction, with full custom parameter control for precise sound design.

Key Features:

What are digital distortion effects? Traditional analog distortion: harmonic saturation, soft clipping. Digital distortion: algorithmic transformation, bit-depth reduction, waveform replacement. Benefits: (1) Creative destruction: Transform sounds beyond recognition. (2) Lo-fi aesthetics: Recreate vintage digital artifacts. (3) Rhythmic interest: Gating and modulation create movement. (4) Industrial textures: Harsh, aggressive sonic character. (5) Precise control: Mathematical rather than empirical processing. Use cases: Industrial music production, sound design for games/film, experimental composition, lo-fi beat making, audio degradation for artistic effect, rhythmic processing.

Technical Implementation: (1) Preset system: Automatic parameter configuration based on 8 factory presets. (2) Bit Crusher algorithm: Quantization via rounding to discrete amplitude levels. (3) Harsh Distortion algorithm: Three-stage processing: zero-crossing detection → amplitude modulation → rhythmic gating. (4) Formula-based processing: Single-pass mathematical transformation using Praat's Formula. (5) Output management: Automatic naming, peak normalization, optional playback and original preservation. Processing is real-time and preserves original timing characteristics.

Quick start

  1. In Praat, select exactly one Sound object.
  2. Run script…distortion_bitcrusher_suite.praat.
  3. Choose Preset from dropdown (recommended for starters):
    • BC: Default (4-bit): Classic bit-crushed sound
    • HD: Balanced: Moderate harsh distortion
    • HD: Heavy Industrial: Extreme transformation
  4. Or select Custom and choose:
    • Effect Type: Bit Crusher or Harsh Distortion
    • Adjust parameters for desired effect
  5. Set Scale_peak (0.99 recommended)
  6. Enable Play_result for immediate audition
  7. Enable Keep_original to preserve source
  8. Click OK — processed sound created with "_Crushed" or "_Distorted" suffix
Quick tip: Start with presets to understand the character of each effect. For bit crushing: try BC: Lo-Fi Digital (3-bit) for classic video game sounds. For harsh distortion: try HD: Stutter Gate for rhythmic, glitchy effects. Use on drum loops, vocals, or full mixes for dramatic transformation. The script automatically switches effect type based on preset selection. Output is automatically normalized to prevent clipping. Original sound is preserved by default — disable "Keep_original" to replace.
Important: DESTRUCTIVE PROCESSING — effects radically transform the original sound. Bit Crusher: Lower quantization levels create more extreme stepping artifacts. Harsh Distortion: Completely replaces waveform content — original timbre is destroyed. Modulation frequencies: Very high frequencies (>500Hz) may cause aliasing. Gate timing: Very short gate periods (<0.01s) create strobe-like effects. Extreme settings: Can produce very loud or harsh results — monitor at safe levels. Original preservation: "Keep_original=0" removes source sound — use with caution.

Distortion Theory

Digital vs Analog Distortion

Fundamental Differences

Analog distortion characteristics:

ANALOG DISTORTION (Tube, Tape, Transistor): - Soft clipping: gradual saturation - Even harmonic emphasis (musical) - Smooth waveform compression - Warm, musical character - Continuous amplitude response DIGITAL DISTORTION (Bit Crusher, Wavefold, etc.): - Hard clipping: abrupt saturation - Odd harmonic creation (harsh) - Stepped quantization artifacts - Cold, aggressive character - Discrete amplitude levels Our focus: Digital-style distortion Bit Crusher: Amplitude quantization Harsh Distortion: Waveform replacement Both create "digital" rather than "analog" artifacts

Why Digital Distortion?

Artistic and technical rationale:

🎛️ Creative Applications

Bit Crusher uses:

  • Lo-fi aesthetics: Vintage digital equipment emulation
  • Reduced bandwidth: Create space in dense mixes
  • Rhythmic interest: Stepped amplitudes create patterns
  • Sound design: Robotic, digital character

Harsh Distortion uses:

  • Aggressive transformation: Complete sound destruction
  • Rhythmic gating: Create stutter and pulse effects
  • Industrial music: Mechanical, factory-like textures
  • Experimental sound: Beyond recognition transformation

Amplitude Quantization

Bit-Depth Reduction Theory

Digital audio fundamentals:

BIT DEPTH = Amplitude resolution Higher bit depth = more amplitude steps = smoother reproduction Lower bit depth = fewer amplitude steps = quantization noise Standard bit depths: 16-bit = 65,536 amplitude levels (CD quality) 8-bit = 256 amplitude levels (early computer audio) 4-bit = 16 amplitude levels (severe degradation) 2-bit = 4 amplitude levels (extreme stepping) Our implementation: Mathematical quantization Not true bit-depth reduction (which affects dynamic range) But creates similar perceptual effect: stepped waveforms Formula: round(x × levels) / levels Example: 4-bit crusher (16 levels) Input: 0.73 → 0.73×16=11.68 → round=12 → 12/16=0.75 Input: -0.42 → -0.42×16=-6.72 → round=-7 → -7/16=-0.4375

Quantization Error and Noise

Mathematical properties:

QUANTIZATION ERROR = Original - Quantized For N levels: maximum error = ±1/(2N) For 4-bit: max error = ±1/32 = ±0.03125 For 2-bit: max error = ±1/8 = ±0.125 ERROR CHARACTERISTICS: - Correlated with signal (not random noise) - Creates harmonic distortion - Stepped waveform appearance - "Granular" amplitude changes PERCEPTUAL EFFECTS: - Buzziness and grit - Loss of subtle details - Added high-frequency content - "Digital" character Our implementation: Preserves original amplitude range Only affects resolution, not overall level

Zero-Crossing Distortion

Waveform Polarity Detection

Fundamental concept:

ZERO-CROSSING = Point where waveform crosses zero amplitude Positive half-cycle: amplitude > 0 Negative half-cycle: amplitude < 0 Our algorithm: Extract polarity information sign(x) = if x > 0 then 1 else -1 fi This preserves ONLY the zero-crossing information Discards ALL amplitude information within each half-cycle Result: Binary waveform representation Only two states: +1 (positive) or -1 (negative) Original waveform shape completely lost Creates extreme distortion character Why this approach? - Completely transforms timbre - Creates square-wave-like result - Preserves rhythmic and phrase information - Extreme but musically useful

Combined Modulation

Layered processing:

HARSH DISTORTION = Three processing stages: STAGE 1: Zero-Crossing Detection output₁ = sign(original) // +1 or -1 only STAGE 2: Amplitude Modulation output₂ = output₁ × (base_amplitude + mod_amplitude × sin(2π × mod_frequency × time)) STAGE 3: Rhythmic Gating output₃ = output₂ × gate_function(time) Where gate_function = if (time MOD gate_period) > gate_duty then 1 else 0 Final: output₃ = sign(original) × (base + mod×sin(2πfₘt)) × gate(t)

Bit Crusher Algorithm

Quantization Mathematics

Core Algorithm

Discrete amplitude mapping:

BIT CRUSHER FORMULA: output = round(input × quantization_levels) / quantization_levels Step-by-step: 1. Scale: input × levels → maps to integer range 2. Round: to nearest integer → discrete steps 3. Rescale: / levels → back to [-1, 1] range Example with quantization_levels = 4: Input: 0.00 → 0.00×4=0.00 → round=0 → 0/4=0.00 Input: 0.24 → 0.24×4=0.96 → round=1 → 1/4=0.25 Input: 0.49 → 0.49×4=1.96 → round=2 → 2/4=0.50 Input: 0.74 → 0.74×4=2.96 → round=3 → 3/4=0.75 Input: 0.99 → 0.99×4=3.96 → round=4 → 4/4=1.00 Properties: - Output only takes discrete values - Maximum levels = quantization_levels + 1 - Symmetric for positive/negative - Preserves zero crossing points

Equivalent Bit Depths

Relationship to digital audio:

Quantization Levels vs Bit Depth:

Levels | Equivalent | Description
2 | 1-bit | Extreme, only ±1.0
4 | 2-bit | Heavy, 4 steps total
8 | 3-bit | Medium, 8 steps
16 | 4-bit | Classic "8-bit" sound
32 | 5-bit | Mild degradation
64 | 6-bit | Subtle stepping
128 | 7-bit | Very subtle
256 | 8-bit | Early computer audio

Note: Our "levels" parameter = 2^(bits)
So 4-bit = 16 levels, 8-bit = 256 levels, etc.

Preset Configurations

Bit Crusher Presets

PresetLevelsEquivalentCharacter
BC: Heavy (2-bit)21-bitExtreme, only ±1.0 output
BC: Lo-Fi Digital (3-bit)32-bitClassic video game sound
BC: Default (4-bit)42-bitStrong degradation
BC: Mild (8-bit)83-bitModerate stepping

Waveform Examples

Original Sine Wave → Bit Crusher Transformation

Original:
Smooth: 0.00 → 0.25 → 0.50 → 0.75 → 1.00 → 0.75 → 0.50 → 0.25 → 0.00

4-level (2-bit):
Stepped: 0.00 → 0.25 → 0.50 → 0.75 → 1.00 → 0.75 → 0.50 → 0.25 → 0.00
(Actually same in this case - sine peaks at quantization points)

3-level:
Stepped: 0.00 → 0.33 → 0.67 → 1.00 → 0.67 → 0.33 → 0.00

2-level (extreme):
Binary: 0.00 → 1.00 → 1.00 → 1.00 → 1.00 → 1.00 → 0.00

Spectral Characteristics

Harmonic Generation

Frequency domain effects:

BIT CRUSHER SPECTRAL EFFECTS: Added harmonics: Quantization creates harmonic distortion More harmonics with fewer levels Odd and even harmonics generated Noise floor: Quantization error appears as noise Noise correlated with signal Perceived as "buzz" or "grit" Aliasing potential: Stepped waveforms have high-frequency content May exceed Nyquist frequency Creates aliasing artifacts Spectral spreading: Concentrated energy spread across spectrum Smears transient attacks Creates "blurry" high frequencies Musical implications: Adds brightness and presence Can mask details in dense mixes Creates "digital" character

Harsh Distortion Algorithm

Three-Stage Processing

Stage 1: Zero-Crossing Detection

Polarity extraction:

ZERO-CROSSING FORMULA: sign(x) = if x > 0 then 1 else -1 fi Input: Any waveform with zero crossings Output: Square wave with same zero-crossing points Example transformations: Sine wave → Square wave Complex waveform → Same zero-crossings but square shape Silent sections → Remains silent (zero input → zero output) Properties: - Completely destroys original timbre - Preserves rhythm and phrase timing - Creates rich harmonic content - Extreme distortion character Why preserve zero-crossings? - Maintains musical timing information - Prevents DC offset issues - Creates musically useful results - More interesting than simple clipping

Stage 2: Amplitude Modulation

Dynamic level variation:

MODULATION FORMULA: amplitude(t) = base_amplitude + mod_amplitude × sin(2π × mod_frequency × t) Parameters: base_amplitude = Constant level offset (0.0-1.0) mod_amplitude = Modulation depth (0.0-1.0) mod_frequency = Modulation rate in Hz Effect: Creates dynamic, evolving amplitude Even with static square wave input Adds movement and interest Can create tremolo-like effects Frequency ranges: 0.1-5 Hz: Very slow evolution 5-20 Hz: Rhythmic pulsation 20-100 Hz: Fluttering effect 100-500 Hz: Buzzing/textural >500 Hz: Pitch-like effects Our typical range: 80-150 Hz for industrial character

Stage 3: Rhythmic Gating

Time-based amplitude control:

GATING FORMULA: gate(t) = if (t MOD gate_period) > gate_duty then 1 else 0 Parameters: gate_period = Total cycle time in seconds gate_duty = "On" time within each cycle Effect: Rhythmic on/off pattern Creates stutter, chopping effects Adds percussive rhythm Can synchronize with musical tempo Timing examples: Period=0.1s, Duty=0.05s: 5Hz, 50% duty cycle Period=0.05s, Duty=0.01s: 20Hz, 20% duty (staccato) Period=0.5s, Duty=0.4s: 2Hz, 80% duty (long pulses) Musical timing: Period=0.5s = 120 BPM quarter notes Period=0.25s = 120 BPM eighth notes Period=0.125s = 120 BPM sixteenth notes

Complete Algorithm

Integrated Formula

Combined processing:

HARSH DISTORTION COMPLETE FORMULA: output = sign(original) × (base_amp + mod_amp × sin(2π × mod_freq × x)) × (if (x MOD gate_period) > gate_duty then 1 else 0 fi) Step-by-step interpretation: 1. sign(original): Extract waveform polarity (+1 or -1) 2. × (base_amp + mod_amp × sin(...)): Apply amplitude modulation 3. × gate_function: Apply rhythmic gating Order of operations: Zero-crossing → Amplitude modulation → Gating Why this order? - Zero-crossing first: establishes basic waveform - Modulation second: adds dynamic variation - Gating last: creates final rhythmic structure Alternative orders possible but this works well

Preset Configurations

Harsh Distortion Presets

PresetBaseModFreqPeriodDutyCharacter
HD: Light Drive0.40.280Hz0.07s0.035sModerate, musical
HD: Balanced0.50.3100Hz0.05s0.025sStandard harsh
HD: Heavy Industrial0.70.4150Hz0.03s0.015sExtreme, aggressive
HD: Stutter Gate0.60.2590Hz0.02s0.01sRhythmic, glitchy

Sonic Characteristics

Preset Audio Characteristics:

HD: Light Drive:
- Moderate distortion level
- Slow modulation (80Hz)
- Gentle gating rhythm
- Good for vocals, guitars

HD: Balanced:
- Standard harsh character
- Medium modulation (100Hz)
- Steady rhythmic pulse
- All-purpose harsh effect

HD: Heavy Industrial:
- Extreme transformation
- Fast modulation (150Hz)
- Aggressive stuttering
- Industrial music, sound design

HD: Stutter Gate:
- Rhythmic emphasis
- Very fast gating (50Hz)
- Glitchy, broken texture
- Electronic, experimental

Parameters & Settings

Bit Crusher Parameters

ParameterRangeDefaultDescription
Quantization_levels2-2564Number of discrete amplitude steps

Harsh Distortion Parameters

ParameterRangeDefaultDescription
Base_amplitude0.0-1.00.5Constant output level
Mod_amplitude0.0-1.00.3Modulation depth
Mod_frequency_hz0.1-2000100Modulation rate
Gate_period_s0.001-1.00.05Gating cycle time
Gate_duty_cycle_s0.001-1.00.025Gate "on" time

Output Parameters

ParameterTypeDefaultDescription
Scale_peakpositive0.99Output peak level
Play_resultboolean1Auto-play after processing
Keep_originalboolean1Preserve source sound

Parameter Guidance

Bit Crusher level selection:
  • 2-4 levels: Extreme degradation, robotic
  • 5-8 levels: Strong lo-fi character
  • 9-16 levels: Moderate digital sound
  • 17-32 levels: Subtle grit and warmth
  • 33+ levels: Very subtle effect
Harsh Distortion modulation ranges:
  • 0.1-5 Hz: Very slow evolution
  • 5-20 Hz: Rhythmic pulsation
  • 20-100 Hz: Fluttering texture
  • 100-500 Hz: Buzzing industrial
  • 500-2000 Hz: Pitch-like effects
Gate timing strategies:
  • Long periods (0.5-1.0s): Phrase-level structure
  • Medium periods (0.1-0.5s): Rhythmic patterns
  • Short periods (0.01-0.1s): Stutter effects
  • Duty cycle > 50%: Mostly "on"
  • Duty cycle < 20%: Staccato bursts

Applications

Sound Design

Use case: Creating industrial, robotic, or destroyed sounds

Technique: Process organic sounds with extreme settings

Examples: Nature recordings → industrial textures, vocals → robotic voices

Lo-Fi Music Production

Use case: Adding vintage digital character to modern productions

Technique: Mild bit crushing on drums, melodies, or full mixes

Benefits: Warm degradation, reduced digital cleanliness

Rhythmic Processing

Use case: Creating stutter, glitch, and rhythmic effects

Technique: Harsh distortion with synchronized gating

Applications: Drum processing, vocal chopping, rhythmic interest

Experimental Music

Use case: Extreme sound transformation for avant-garde composition

Technique: Combine both algorithms or use extreme parameter settings

Results: Beyond-recognition sound manipulation

Practical Workflow Examples

🎵 Lo-Fi Drum Processing

Goal: Add vintage digital character to drum loops

Setup:

  • Effect: Bit Crusher
  • Preset: BC: Lo-Fi Digital (3-bit)
  • Source: Clean drum loop
  • Result: Classic video game drum sound

Tip: Blend with original for subtle effect

🥁 Industrial Rhythm Creation

Goal: Transform ambient sounds into rhythmic patterns

Setup:

  • Effect: Harsh Distortion
  • Preset: HD: Stutter Gate
  • Source: Sustained pad or noise
  • Result: Pulsing industrial rhythm

Tip: Adjust gate timing to match project tempo

🎭 Vocal Destruction

Goal: Create robotic or demonic vocal effects

Setup:

  • Effect: Harsh Distortion
  • Preset: HD: Heavy Industrial
  • Source: Clean vocal recording
  • Result: Aggressive distorted vocals

Tip: Use sparingly for dramatic impact

Advanced Techniques

Multi-stage processing:
  • Stage 1: Apply bit crusher for basic degradation
  • Stage 2: Apply harsh distortion for extreme transformation
  • Stage 3: Blend with original for controlled effect
  • Result: Complex, layered distortion character
Parameter automation:
  • Dynamic bit crushing: Vary quantization levels over time
  • Evolving modulation: Change modulation frequency progressively
  • Rhythmic variation: Automate gate timing for complex patterns
  • Result: Evolving, dynamic distortion effects

Troubleshooting Common Issues

Problem: Output too extreme/harsh
Cause: Very low quantization levels or extreme distortion settings
Solution: Use milder presets, increase quantization levels, reduce modulation depth
Problem: Aliasing artifacts
Cause: High modulation frequencies or extreme bit crushing
Solution: Reduce modulation frequency, use milder bit crushing, or oversample source
Problem: Rhythm doesn't match project tempo
Cause: Gate timing not synchronized to musical tempo
Solution: Calculate gate period based on BPM: period = 60/BPM for quarter notes
Problem: Lost original sound accidentally
Cause: Keep_original disabled without backup
Solution: Always keep backups, use Keep_original=1 as default

Algorithmic Extensions

Enhanced Bit Crushing

Advanced Quantization

Beyond basic rounding:

DITHERED QUANTIZATION: output = round((input + noise) × levels) / levels Adds controlled noise before quantization Breaks up correlated quantization error Reduces "buzziness", adds "grit" NON-UNIFORM QUANTIZATION: output = f(round(f⁻¹(input) × levels)) / levels Nonlinear mapping before/after quantization Can emphasize or de-emphasize certain levels More musically intelligent stepping MULTIBAND BIT CRUSHING: Split into frequency bands Apply different quantization to each band Preserve lows while crushing highs (or vice versa) More controlled degradation

Enhanced Harsh Distortion

Advanced Waveform Synthesis

Beyond simple square waves:

WAVEFOLDING DISTORTION: output = arcsin(sin(π × input × fold_factor)) / (π/2) Creates complex harmonic structures More musical than simple clipping Analogous to analog wavefolding WAVETABLE SYNTHESIS: Use zero-crossing to select wavetable position output = wavetable[phase + modulation] Can use any waveform shape Extreme timbral transformation PHASE DISTORTION: Modify phase relationship between harmonics output = original(phase × distortion_function) Creates inharmonic, metallic sounds Very complex results from simple inputs

Hybrid Approaches

Combining Algorithms

Creative processing chains:

SERIAL PROCESSING: Bit Crusher → Harsh Distortion Adds grit before extreme transformation More complex harmonic structure PARALLEL PROCESSING: Process original with both algorithms separately Mix results for hybrid character Blend control for subtlety FEEDBACK COMBINATIONS: Output → Bit Crusher → Harsh Distortion → feedback Creates evolving, self-modifying effects Extreme sound destruction MULTIRATE PROCESSING: Bit crush at lower sample rate Upsample with interpolation Harsh distortion at full rate Combines multiple degradation types