@maruaudio/dsp/noise/record-texture, authored in Maru, generates stereo vinyl and cassette textures in three modes: noise only, to be added to audio, sounding on silent input when enabled.
| Mode | Constant | Law |
|---|---|---|
| Crackle | RECORD_TEXTURE_CRACKLE (0) | Seeded bipolar impulses at a Poisson rate, each feeding a 2 ms exponential tail, through a one-pole tone filter per channel |
| Dust | RECORD_TEXTURE_DUST (1) | The same with a 0.2 ms tail |
| Hum | RECORD_TEXTURE_HUM (2) | (sin 2πφ + h·sin 4πφ)/(1 + h) × level, the right channel offset by a phase |
Impulse timing, level and pan come from @maru/noise-xorshift32; the pan is scaled by Spread and split with gains (1 ∓ pan)/2.
Parameters
configureRecordTexture(state, mode, first, second, third, fourth) sets everything through clampFiniteWithFallback (@maru/math-range); the arguments change meaning with the mode.
| Argument | Crackle and dust | Hum |
|---|---|---|
mode | Rounded, 0 to 2; non-finite → 0 | |
first | Rate 0 to 200 events/s; non-finite → 0 | 60 Hz when ≥ 55, otherwise 50 Hz |
second | Impulse amplitude 0 to 1 | Level 0 to 0.1 |
third | Tone 500 Hz to min(16 kHz, 0.45 × rate); non-finite → 16 kHz | Harmonic 0 to 1 |
fourth | Spread 0 to 1 | Right-channel phase 0 to 180° |
Other non-finite values give 0. Init configures silent crackle (rate 0).
Lifecycle
initRecordTexture(sampleRate, seed) (8 to 384 kHz, fallback 48 kHz; seed 0 → 2463534242) outside the callback → configure → recordTextureTick, reading outLeft and outRight → resetRecordTexture, which restores the seed, zeroes phase, tails and outputs and resets both tone filters.
When to use it
Surface noise or mains hum under a track, from a repeatable seed.
Limits
- Stereo out, no input; no typed-array storage. Spread 0 gives identical channels and rate 0 exact silence.
- Two states with the same seed give the same stream and reinforce when summed.