Hard Clip (Variable Knee) — User Guide
Variable‑knee hard clipper/limiter with three‑region processing: linear, quadratic knee, and hard ceiling.
What this does
This script implements hard clipping with variable knee — a versatile clipping/limiting effect that smoothly transitions from linear to hard‑limited regions via a configurable quadratic knee. Three processing zones: (1) Linear: Below threshold‑knee, signal passes unchanged. (2) Knee: Between threshold±knee, quadratic curve provides smooth transition. (3) Hard Clip: Above threshold+knee, signal is hard‑limited to threshold. Key features: (1) Variable Knee Width: From 0.001 (near‑hard) to 0.5 (very soft). (2) 5 Built‑in Presets: Brickwall limiter, soft clipper, hard distortion, subtle glue, Fuzz Face emulation. (3) Drive + Threshold: Independent control of input gain and clipping ceiling. (4) Mathematical precision: Uses boolean logic for efficient three‑zone processing. (5) Visualization: Shows transfer function with knee region highlighted.
Key Features:
- Three‑zone processing — Linear, knee, hard clip
- Variable knee width — Continuous control from hard to soft clipping
- 5 Built‑in Presets — From transparent limiting to aggressive distortion
- Boolean logic implementation — Efficient sample‑by‑sample processing
- Drive + Threshold independence — Separate input gain and output ceiling
- Transfer function visualization — Clear display of knee behavior
Technical Implementation: (1) Absolute value processing: Process absolute amplitude, then restore sign. (2) Three‑zone logic: Boolean switches determine zone: linear, knee, or hard clip. (3) Knee mathematics: Quadratic curve: y = T − ((T+K − |x|)² / (4K)) where T=threshold, K=knee width. (4) Formula construction: Dynamically builds Praat formula string using boolean algebra. (5) Efficient processing: Single‑pass Formula application with all logic embedded. (6) Visualization: Plots transfer function showing all three zones with threshold lines.
Quick start
- In Praat, select exactly one Sound object.
- Run script… →
apply_hard_clip.praat. - Choose a Preset (overrides sliders) or "Manual" to use sliders.
- Adjust Drive (input gain before clipping).
- Set Threshold (clipping ceiling level).
- Choose Knee_Width (transition softness: 0.01=hard, 0.5=soft).
- Set Output_Gain for volume compensation.
- Enable Draw_visualization to see transfer function.
- Click OK — effect applied, result named "originalname_Clip_presetname".
Clipping Theory
Three‑Zone Processing Model
📊 Processing Zones
Visual interpretation: The knee creates a smooth "rounded corner" between the linear region and the hard‑clipped ceiling. Wider knee = more gradual transition, softer sound. Narrower knee = sharper transition, harder sound.
Knee Mathematics
Quadratic Bézier Implementation
Knee Width Interpretation
K=0.01 (Near‑hard): • Knee region: 0.69‑0.71 • Very sharp transition • Sounds like: Classic hard clipping, rich odd harmonics
K=0.1 (Moderate): • Knee region: 0.6‑0.8 • Noticeable rounding • Sounds like: Musical soft clipping, balanced harmonics
K=0.3 (Wide): • Knee region: 0.4‑1.0 • Very gradual transition • Sounds like: Gentle saturation, minimal distortion
K=0.5 (Very wide): • Knee region: 0.2‑1.2 • Extremely soft • Sounds like: Transparent limiting, "glue" effect
Boolean Logic Implementation
⚡ Efficient Zone Selection
Why boolean logic? This allows all three zones to be computed in a single Praat Formula command without conditional statements (if/then), which Praat's Formula doesn't support directly. The boolean switches act as "gates" that only allow one zone's contribution at a time.
Parameter Interactions
Drive (Input Gain)
Effect: Multiplies input before clipping threshold detection.
Mathematical: Effective input to clipper = original × Drive.
Interaction: Higher Drive pushes more signal into knee/clip zones. With Threshold fixed, increasing Drive increases amount of clipping.
Threshold (Clipping Ceiling)
Effect: Maximum output amplitude before Output_Gain.
Mathematical: Hard ceiling at y = Threshold in clip zone.
Interaction: Lower Threshold causes earlier/more clipping. With Drive fixed, lowering Threshold increases clipping.
Knee_Width (Transition Softness)
Effect: Width of quadratic transition region.
Mathematical: Determines range T±K where knee operates.
Interaction: Affects harmonic content — narrower = more odd harmonics, wider = more even harmonics.
Output_Gain (Volume Compensation)
Effect: Multiplies after clipping.
Mathematical: Final output = clipped_signal × Output_Gain.
Interaction: After heavy clipping, peaks are reduced; Output_Gain can restore perceived loudness.
Harmonic Generation Analysis
🎵 Harmonic Characteristics
Hard Clip (K→0): • Rich odd harmonics (3rd, 5th, 7th...) • Sharp corners → high‑frequency content • Can cause aliasing • Classic "digital" distortion sound
Soft Clip (K=0.2‑0.3): • More even harmonics (2nd, 4th...) • Smooth transition → fewer high harmonics • Less aliasing • "Analog" warmth character
Very Soft (K>0.4): • Minimal harmonics • Gentle saturation • Primarily dynamic range control • "Glue" or "warmth" without obvious distortion
Low Threshold + High Drive: • Heavy harmonic generation • Complex intermodulation • "Fuzz" or "overdrive" character • Can become noisy/mushy
Parameters & Presets
Common Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Preset | optionmenu | Manual | 5 built‑in presets or manual control |
| Drive | real | 1.0 | Input gain before clipping (multiplier) |
| Threshold | real | 0.5 | Clipping ceiling (0‑1 scale) |
| Knee_Width | real | 0.2 | Transition softness (0.001‑0.5) |
| Output_Gain | real | 0.9 | Post‑clipping volume compensation |
| Draw_visualization | boolean | 1 (yes) | Show transfer function plot |
| Play_result | boolean | 1 (yes) | Auto‑play after processing |
Built‑in Presets
| Preset | Drive | Threshold | Knee_Width | Output_Gain | Character |
|---|---|---|---|---|---|
| Brickwall Limiter | 1.2 | 0.8 | 0.05 | 0.95 | Transparent peak control, minimal distortion |
| Soft Clipper | 2.0 | 0.6 | 0.4 | 0.8 | Musical saturation, analog‑like warmth |
| Hard Distortion | 5.0 | 0.4 | 0.01 | 0.6 | Aggressive guitar‑style clipping |
| Subtle Glue | 1.0 | 0.7 | 0.5 | 1.0 | Gentle loudness enhancement, "glue" effect |
| Fuzz Face (Low Thresh) | 8.0 | 0.1 | 0.1 | 0.5 | Classic fuzz‑style heavy distortion |
Preset Design Philosophy
🎛️ Preset Characteristics Explained
Brickwall Limiter: • High Threshold (0.8) = clips only extreme peaks • Very narrow Knee (0.05) = near‑instant limiting • Moderate Drive (1.2) = gentle gain boost into limiter • High Output_Gain (0.95) = minimal level reduction • Use: Final mastering, peak protection
Soft Clipper: • Moderate Threshold (0.6) = noticeable saturation • Wide Knee (0.4) = smooth, musical transition • Higher Drive (2.0) = pushes signal into knee • Lower Output_Gain (0.8) = compensates for saturation • Use: Analog‑style saturation, warmth addition
Hard Distortion: • Lower Threshold (0.4) = aggressive clipping • Very narrow Knee (0.01) = near‑hard clipping • High Drive (5.0) = heavy signal boost • Low Output_Gain (0.6) = level reduction after heavy clipping • Use: Guitar distortion, aggressive sound design
Subtle Glue: • Moderate Threshold (0.7) = gentle limiting • Very wide Knee (0.5) = extremely soft transition • Unity Drive (1.0) = no additional gain • Unity Output_Gain (1.0) = level preservation • Use: Mix bus "glue", gentle loudness enhancement
Fuzz Face: • Very low Threshold (0.1) = constant heavy clipping • Moderate Knee (0.1) = some rounding • Very high Drive (8.0) = massive gain boost • Low Output_Gain (0.5) = volume reduction for safety • Use: Classic fuzz tones, extreme distortion
Parameter Relationships
Applications
Mastering & Final Limiting
Use case: Transparent peak control for mastering
Technique: Use Brickwall Limiter preset
Tip: Set Threshold just above program peaks, minimal Drive (1.0‑1.3), very narrow Knee (0.01‑0.05)
Advanced: Use in series with compression: compress for dynamics, then clip for final peaks
Analog‑Style Saturation
Use case: Adding warmth and harmonics
Technique: Use Soft Clipper preset
Tip: Moderate Drive (1.5‑3.0), Threshold around 0.6‑0.7, wide Knee (0.3‑0.5)
Advanced: Apply to individual tracks rather than mix bus for controlled saturation
Guitar & Bass Distortion
Use case: Amp‑like distortion tones
Technique: Use Hard Distortion or Fuzz Face presets
Tip: High Drive (4‑10), low Threshold (0.1‑0.4), narrow‑medium Knee (0.05‑0.2)
Advanced: Chain multiple instances: soft clip → hard clip for complex distortion
Drum & Percussion Processing
Use case: Drum bus "smash" or transient shaping
Technique: Moderate Drive (2‑4), Threshold around transients, adjust Knee for hardness
Tip: Fast‑attack clipping can tame drum transients; parallel process for blend control
Advanced: Use envelope follower to modulate Threshold for dynamic drum processing
Vocal "In‑Your‑Face" Effect
Use case: Aggressive vocal presence
Technique: Moderate Drive (1.5‑2.5), Threshold just above average level
Tip: Use wider Knee (0.3‑0.4) for vocal smoothness, narrower for aggression
Advanced: De‑ess before clipping to prevent sibilance distortion
Practical Workflow Examples
🎚️ Mastering Chain Clipper
Goal: Final peak control without audible distortion
Settings:
- Preset: Brickwall Limiter (modified)
- Drive: 1.1 (gentle boost)
- Threshold: 0.85 (clip only highest peaks)
- Knee_Width: 0.02 (very sharp)
- Output_Gain: 0.98 (minimal reduction)
Result: Transparent 1‑2 dB peak reduction, no audible distortion
🎸 Rock Guitar Rhythm
Goal: Crunchy rhythm guitar tone
Settings:
- Preset: Hard Distortion (modified)
- Drive: 3.5
- Threshold: 0.5
- Knee_Width: 0.15 (some rounding)
- Output_Gain: 0.8
Result: Aggressive but defined rhythm distortion, not too fizzy
🥁 Parallel Drum Smash
Goal: Aggressive parallel drum compression via clipping
Settings:
- Preset: Soft Clipper (modified)
- Drive: 4.0
- Threshold: 0.4
- Knee_Width: 0.25
- Output_Gain: 0.6
Technique: Process copy of drum bus, blend 10‑30% with dry
Result: Punchy, aggressive drums without losing transients
Advanced Techniques
Troubleshooting Common Issues
Cause: Knee_Width too narrow (< 0.05), creating near‑hard clipping
Solution: Increase Knee_Width to 0.1‑0.3 for smoother transition
Cause: Threshold too low and/or Drive too high
Solution: Increase Threshold, decrease Drive, or both
Cause: Threshold too high relative to signal level
Solution: Decrease Threshold or increase Drive
Cause: Output_Gain too low after peak reduction
Solution: Increase Output_Gain (try 1/Threshold as starting point)
Cause: Hard clipping of high‑frequency content
Solution: Increase Knee_Width, reduce Drive, or use oversampling
Mathematical Deep Dive
Transfer Function Analysis
Harmonic Analysis of Knee Clipping
For sinusoid input A sin(ωt):