@maruaudio/dsp/filters/partitioned-convolution convolves one channel with an impulse response of up to 2^20 frames by uniformly partitioned overlap-save: every B samples the last 2B inputs enter a frequency-domain delay line and the output is IFFT(Σ H_j·X_{p−j}), the linear convolution of Web Audio ConvolverNode. Input is f32, taps fround(tap·gain), the rest f64. Two IR slots share the delay line, so a new IR is prepared in steps and crossfaded in.
const state = initPartitionedConvolution(144000, 256, true)
loadPartitionedConvolutionIr(state, ir, 0, ir.length, 1)
const y = partitionedConvolutionTick(state, x)Parameters
There are no setters; layout is passed to init and the IR to the load calls.
| Argument | Range as coded | Unit |
|---|---|---|
partitionSize | Rounded up to a power of two, 16 to 16384; at most 256 with zeroLatency | frames |
zeroLatency | true: a direct head (@maru/filters-convolution) covers the first B taps, latency 0; false: latency B | flag |
tailPartitionSize (two-stage init) | Power of two, 2B to 16384; ≤ 0 gives the single-stage layout | frames |
irFrames, gain | Frames clamped to maxIrFrames (at most 2^20); gain is a scalar, no normalization | frames, linear |
crossfadeFrames, law | ≤ 0 swaps at once; CROSSFADE_LINEAR or CROSSFADE_EQUAL_POWER | frames |
Lifecycle
initPartitionedConvolution or initPartitionedConvolutionTwoStage allocates both slots and the delay lines; nothing allocates afterwards. Load an IR with loadPartitionedConvolutionIr, or beginPartitionedConvolutionIr → preparePartitionedConvolutionIr (budgeted, returns partitions left) → commitPartitionedConvolutionIr. Render with partitionedConvolutionTick or processPartitionedConvolutionBlock (f32 output). resetPartitionedConvolution clears history and keeps loaded IRs; clearPartitionedConvolution empties both slots. Begin and commit refuse during a crossfade or an armed swap.
When to use it
Reverb and room impulses, or cabinet IRs longer than 256 taps.
Limits
- Mono: stereo IRs are two states. Normalization is the caller's.
- Single stage: one forward FFT, the full delay-line multiply-accumulate and one inverse FFT on the sample completing a partition; both slots run only while crossfading. A two-stage commit is heard at the second tail boundary.