@maruaudio/dsp/distortion/color-shaper is a wet-only mono transfer in three modes on the input times the drive gain g, each followed by a 10 Hz DC blocker (@maru/filters-dc-block), a one-pole tone filter (@maru/filters-tone) and an output trim. tanh is the exponential form bounded to ±20, and the asymmetric denominator is at least 0.001.
| Mode | Constant | Transfer, with character c |
|---|---|---|
| Hard clip | COLOR_SHAPER_HARD_CLIP (0) | Clamp to ±(0.1 + 0.9c) |
| Asymmetric | COLOR_SHAPER_ASYMMETRIC (1) | (tanh(x + c/2) − tanh(c/2)) / (tanh(g + c/2) − tanh(c/2)) |
| Rectifier | COLOR_SHAPER_RECTIFIER (2) | abs(x) when c ≥ 0.5, else max(0, x) |
Parameters
configureColorShaper(state, mode, driveDb, character, toneHz, outputDb) uses clampFiniteWithFallback (@maru/math-range); mode is rounded to 0 to 2 (fallback 0).
| Argument | Range | Fallback | Init |
|---|---|---|---|
driveDb | 0 to 36 dB (@maru/math-decibels) | 0 dB | 0 dB |
character | 0 to 1: ceiling, bias or half/full wave | 0 | 1 |
toneHz | 500 Hz to min(16 kHz, 0.45 × rate) | 16 kHz | 16 kHz |
outputDb | −24 to +6 dB | 0 dB | 0 dB |
Lifecycle
initColorShaper(rate) (8 to 384 kHz, fallback 48 kHz) → configureColorShaper → colorShaperTick → resetColorShaper, which clears both filters and keeps the settings. Ticks allocate nothing and do no I/O.
When to use it
Hard clipping, biased saturation or octave-up rectification on drums, bass or synths, with the DC removed.
Limits
- Mono sample tick, wet only; non-finite input becomes 0.
- No oversampling: hard edges can alias. Transfers, not tube or tape models.