@maruaudio/dsp/distortion/bitcrusher reduces sample rate and bit depth with Soundcraft's LoFi hold and quantizer law. A one-pole low-pass (@maru/filters-one-pole) filters the input; a phase accumulator advancing by crushRate / rate re-samples it; each new sample is boosted, quantized to a signed step of 2^(1 − bits) with half steps rounded away from zero, clamped to ±1 and held. The output is (x × (1 − mix) + held × mix) × 10^(−boostDb/40).
Parameters
| Setter | Range (clampFiniteWithFallback) | Fallback | Default |
|---|---|---|---|
setBitcrusherSampleRate | 20 Hz to rate/2; also sets the filter to 0.45 × that | rate/2 | rate/2, filter open |
setBitcrusherTone | 20 Hz to 0.45 × rate, independent filter cutoff | 20 Hz | |
setBitcrusherBitDepth | 1 to 16, floored | 8 | 8 |
setBitcrusherBoost | −12 to +24 dB | 0 | 0 dB |
setBitcrusherMix | 0 to 1 | 1 | 1 |
Lifecycle
initBitcrusherNode(rate) (rate 8 to 192 kHz, fallback 48 kHz) → prepareBitcrusherNodeSampleRate → setters → bitcrusherNodeTick → resetBitcrusherNode (phase, hold and filter memory). Prepare re-clamps the crush rate and restores the crush-rate filter law, so call setBitcrusherTone again after it. Ticks allocate nothing and do no I/O.
When to use it
Lo-fi reduction on drums, keys or a full mix: fewer bits for coarser steps, a lower crush rate for longer holds.
Limits
- Mono sample tick; no noise is added. Input is clamped to ±10⁶ (non-finite → 0); wet output stays within ±1.
- Output compensation is half the boost in decibels, applied to dry and wet.
- The signed grid replaced an earlier OpenDAW-attributed quantizer and intentionally changes its output.