processConvolutionBlock returns false before changing history or output when its integer [fromIndex, toIndex) range exceeds either buffer. It returns true after a valid block. Identical source/output spans support in-place use; other spans must be disjoint. During preparation, isConvolutionBlockMemoryValid checks that the borrowed views have fixed backing and do not overlap private history or impulse storage. Recheck whenever installing different views.
@maruaudio/dsp/filters/convolution is a zero-latency direct FIR convolver, y[n] = x[n]·(1 − mix) + outputGain·mix·Σ h[k]·x[n−k], capped at CONVOLUTION_MAX_TAPS (256) mono taps. History and impulse are fixed 256-word f32 arrays allocated at init; the sum runs in double. FIR taps are rate agnostic, so no sample rate enters the state.
const state = initConvolutionNode()
loadConvolutionImpulse(state, ir.length, ir.length, (tap) => ir[tap])
const y = convolutionNodeTick(state, x)Parameters
| Setter | Range the setter enforces | Default |
|---|---|---|
loadConvolutionImpulse(state, available, requestedTaps, readTap) | Length bounded to 0 to available and 256; taps rounded to f32, the rest zeroed; returns the accepted length | Empty (0 taps) |
setConvolutionMix | 0 to 1 | 1 (fully wet) |
setConvolutionOutputGain | 0 to 2 (linear, wet path) | 1 |
Lifecycle
initConvolutionNode → loadConvolutionImpulse (control thread, it calls the caller's readTap) → mix and gain setters → convolutionNodeTick per sample or processConvolutionBlock over a range → resetConvolutionNode, which clears the history and write position and keeps the impulse. The block entry rounds each output to f32 and accepts any block partition.
When to use it
Short cabinet, coloration or tone-shaping impulses that must add no latency. At 48 kHz, 256 taps is 5.33 ms; long impulses and reverbs belong to @maru/filters-partitioned-convolution.
Limits
- Mono; one sample per tick, at most 256 multiply-adds.
- The impulse is not resampled: the host resamples it before loading.
- The loop has a literal 256 bound with the IR length as an inner guard.
convolutionDirectSumis shared with the partitioned convolver's head. - Clamps are the kernel node's conditional clamp; a NaN mix passes through.
audio-kernelskeeps the PCM16 impulse decoding and render entry.