Distortion / saturation — non-linear waveshaping
- Status
- calibrated
- Updated
- Family
- effect, 26 packages under it
- Plugin
distortion, effect, streaming, 3 parameters- Category
- effects
- Licence
- MIT
- Dependencies
- none
- Downloads
- 3,376 last month
- Tests
- 138 in audiojs/effect's CI, passed at 5ff5a84,
Listen
// "Local Forecast" by Kevin MacLeod (incompetech.com), CC BY 4.0, incompetech.com/music/royalty-free/faq.html
audio('/samples/music/modern/local-forecast.mp3').distortion()
// "Local Forecast" by Kevin MacLeod (incompetech.com), CC BY 4.0, incompetech.com/music/royalty-free/faq.html
Parameters
drive- 0.5
- 0 to 1
type- soft, hard, tanh, foldback
mix- 1
- 0 to 1
import distortion from '@audio/effect-distortion'
Four waveshaping types: cubic soft clip, hard clip, tanh saturation, and wavefolding.
drive distortion amount 0–1 (default 0.5, maps to 1–10× input gain) · type 'soft' | 'hard' | 'tanh' | 'foldback' (default 'soft') · mix wet/dry 0–1 (default 1) · fs sample rate
import distortion from '@audio/effect-distortion'
// Soft saturation
let p = { drive: 0.6, type: 'soft', fs: 44100 }
for (let buf of stream) distortion(buf, p)
// Hard clip
distortion(buf, { drive: 0.8, type: 'hard' })
// Tanh (asymptotically smooth, never clips hard)
distortion(buf, { drive: 0.5, type: 'tanh' })
// Wavefolding (metallic/harsh)
distortion(buf, { drive: 0.7, type: 'foldback' })
| type | character | clamps at ±1 |
|---|---|---|
soft |
cubic saturation, smooth knee | yes |
hard |
brickwall clip, harsh | yes |
tanh |
asymptotically smooth | approaches 1 |
foldback |
metallic, complex harmonics | yes |
Use when: guitar overdrive, tube saturation, lo-fi crunch, harmonic enrichment
Not for: transparent limiting (use limiter)
Part of @audio/effect — the effect family umbrella. This README is generated from the umbrella docs.
MIT © audiojs