Transistor/console saturation — odd-symmetric cubic, 3rd-harmonic dominant
- Status
- calibrated
- Updated
- Family
- saturate, 5 packages under it
- Plugin
transistor, effect, streaming, 2 parameters- Category
- effects
- Licence
- MIT
- Dependencies
- 1 package, all permissive: MIT
- Downloads
- 2,238 last month
- Tests
- 15 in audiojs/saturate's CI, passed at 027ffbc,
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').transistor()
// "Local Forecast" by Kevin MacLeod (incompetech.com), CC BY 4.0, incompetech.com/music/royalty-free/faq.html
Parameters
drive- 2
- 0.5 to 10
mix- 1
- 0 to 1
import transistor from '@audio/saturate-transistor'
Solid-state/console-style saturation: an odd-symmetric cubic soft clip (v − v³/3, hard-limited past ±1). Odd symmetry means only odd harmonics (3rd-dominant) appear — no DC shift, no even-harmonic warmth, the "console" color as distinct from tube's asymmetric even-harmonic signature. Oversampled (windowed-sinc up → shape → windowed-sinc down) to keep the extra harmonics from aliasing.
transistor(data, { drive: 3, fs: 44100 })
transistor(data, { drive: 6, mix: 0.5 })
| Param | Default | |
|---|---|---|
drive |
2 |
pre-gain into the cubic soft-clip curve |
fs |
44100 |
sample rate |
oversample |
4 |
oversample factor; 1 disables oversampling (naive, aliased) |
mix |
1 |
0..1 — wet/dry blend |
Mutates data in place and returns it (same array reference, not a copy). 3rd-harmonic energy measurably exceeds 2nd-harmonic at equal drive (odd-dominant) — verified in the family test suite via Goertzel analysis.
stream(block, { drive: [3], mix: [1] }, state(1024)) is the same transfer in calls of any size (up to the size given to state), oversampled 4×, its state carried from call to call. The whole call reads 31 samples ahead of each output; a stream cannot, so its output is LATENCY (31) samples late, and moves RING (31) samples past that once its input stops (the oversampler is @audio/resample-sinc's, on the arithmetic the whole call resamples with). Shifted back by LATENCY it is the whole call's output bit for bit, except within 31 samples of the ends of a whole signal. Values arrive as a host gives them to a processor, each a 1-length array, read at each call. The ./audio processor runs it on each channel: latency 31 samples, tail 31 samples, drive and mix live: each declares smoothing (20 ms) and is glided sample by sample along the host's ramp, 32 samples late, so a moved value is one line however the host cut its calls and a held one is the value itself, bit for bit (lanes after the length: drive and mix from 0 and stride).
Use when: solid-state/console-style "grit" and edge.
Not for: warm even-harmonic tube color (use tube) or a plain normalized tanh (use waveshaper).
Part of the @audio/saturate family.
MIT © audiojs