audio

@audio/dynamics-softclip0.3.0

Static waveshaping

Static waveshaping — no envelope, no time state. Deterministic per-sample

Status
pending calibration
Updated
Family
dynamics, 17 packages under it
Plugin
softclip, effect, streaming, 4 parameters
Category
effects
Licence
MIT
Dependencies
1 package, all permissive: MIT
Downloads
2,311 last month
Tests
92 in audiojs/dynamics's CI, passed at 2ee3ad9,

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').softclip()

// "Local Forecast" by Kevin MacLeod (incompetech.com), CC BY 4.0, incompetech.com/music/royalty-free/faq.html

Parameters

  • effect
  • streaming
  • latency
curve
tanh, atan, cubic, sin, hard
drive
1
0.1 to 20
ceiling
1
0.05 to 1
oversamplefixed
1
1 to 8
import softclip from '@audio/dynamics-softclip'

Static waveshaping — no time state, no pumping. Maps input through a fixed transfer curve; peaks saturate smoothly, introducing controlled harmonic content.

Hard/high-drive clipping generates harmonics above Nyquist that fold back as audible aliasing. oversample (1/2/4/8, default 1) runs the transfer at N× rate and decimates back down through a windowed-sinc anti-alias filter, same technique as @audio/saturate's oversampled shapers — oversample: 1 is the exact non-oversampled path (no resampling, zero cost).

import softclip from '@audio/dynamics-softclip'

softclip(data, { curve: 'tanh', drive: 1.5 })
softclip(data, { curve: 'cubic', drive: 2, ceiling: 0.9 })
softclip(data, { curve: 'hard', drive: 4, oversample: 4, fs: 44100 })   // clean high-drive clip
Param Default
curve 'tanh' 'tanh', 'atan', 'cubic', 'sin', 'hard'
drive 1 input pre-gain
ceiling 1 output asymptote
oversample 1 1, 2, 4, 8 — anti-aliased oversampling
fs 44100 Hz, sample rate (only used when oversample > 1)

Use when: gentle peak control with musical saturation, avoiding pumping artifacts of a limiter, lo-fi character; oversample for hard/high-drive clipping that must stay alias-free.
Not for: transparent true-peak safety — use limiter. Clean gain reduction — use compressor.


Part of @audio/dynamics — the dynamics family umbrella. This README is generated from the umbrella docs.

MIT © audiojs