Skip to content

Add a host convolver and CONVO, a convolution reverb - #34

Closed
mparrett wants to merge 5 commits into
nooga:masterfrom
mparrett:feat/convolver
Closed

mparrett wants to merge 5 commits into
nooga:masterfrom
mparrett:feat/convolver

Conversation

@mparrett

@mparrett mparrett commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

This adds convolution to Slab: a host service that convolves an effect machine's input with an impulse response, and CONVO, a convolution reverb built on it. A demo is in songs/convolver_demo.py; the video below plays the same phrase dry, through verb2's big hall for reference, through CONVO's synthetic hall, and through CONVO with a bowed cymbal as the IR.

convolver-demo.mp4

Why the host does the convolution

A 3.5 s stereo IR is about 336,000 multiply-adds per sample done directly, far past a track's budget. FFT convolution in blocks is cheap, but block FFTs and partition spectra aren't what dsp: kernels are for. So the host convolves and hands the kernel the result, and everything after it (predelay, filters, width, mix) stays in fy.

What's here

  • src/convolver.zig: uniform partitioned overlap-save with N = 256. The IR is resampled, scaled so white noise keeps its level, and transformed into partition spectra when it loads, off the audio thread. Per block, the audio thread does one forward FFT, a multiply-accumulate over the partitions, and one inverse FFT; left and right share each transform as l + i·r. process() doesn't allocate.
  • A convolver manifest word, used in place of asset. The IR loads as an asset, so the UI can swap it and presets can name one. The kernel reads the result as io.cv-l / io.cv-r, 256 samples late, and reports that with latency!.
  • CONVO (machines/convo, kernel in kernels/07-effects/convo.fy): PREDELAY, LO CUT, HI CUT, WIDTH, LEVEL and MIX. Two IRs ship with a preset each: a synthetic stereo hall (generated, not recorded) and a bowed cymbal from VSCO 2 CE (CC0).
  • slabkit's fx() takes assets= and carries a preset's assets, as track() already does, so a song can choose an effect's IR.
  • docs/46 describes the design and its limits; CHANGELOG and the machine reference are updated. The machine reference also picks up FX Rack's master-loud preset, which it was missing; that's a separate commit.

CONVO with the 3.5 s hall costs about 930 ns per sample in a ReleaseFast bench, under 5% of a core.

Limits

This is a prototype, and docs/46 lists what it doesn't do yet:

  • The IR is built for 48 kHz and isn't rebuilt when the session rate changes. At 96 kHz the room plays at half its length and an octave up. Rebuilding on a rate change, off the audio thread, would fix it; I left it out to keep this first cut small, and I'm happy to add it here if you'd rather.
  • Swapping the IR cuts a ringing tail; there's no crossfade.
  • Partitions are uniform, so cost grows linearly with IR length. Non-uniform partitions would make long IRs cheaper.
  • One IR per machine, effects only.

Testing

  • zig build test passes, including two convolver tests: output matches direct convolution N samples late with a stereo IR, and a mono IR feeds both channels and reset clears the tail.
  • zig build bench -- --all --check: every golden is bit-exact, and CONVO's are recorded. The run still exits 1 because shift2, resonator2, buffer2 and phaser2 have no goldens on master.

🤖 Generated with Claude Code

mparrett and others added 5 commits October 31, 2026 18:38
…h an IR (prototype)

A machine declares an impulse response with `convolver` (an asset kind),
and the host convolves the stereo input with it by uniform partitioned
overlap-save (256-sample partitions, the fixed FFT in src/fft.zig), handing
the kernel the result per sample as io.cv-l / io.cv-r, 256 samples late.
The engine is built off the audio thread and published with the asset
bindings; a replaced one retires through the same handoff. Effects now
load and save their asset files in projects, so a project can pick the IR.

Prototype for listening before a proposal: the IR is built for 48 kHz
only, a swap has no crossfade, and four-channel true-stereo IRs aren't read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An effect can now load a file by asset name from a song script, which
CONVO's IR needs: fx("convo", assets={"room": ...}). A preset's own
assets come with it, as they do on tracks; no effect preset carried any
before CONVO's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The host convolves the input with an impulse response; PREDELAY, LO CUT,
HI CUT, WIDTH, LEVEL and MIX run in fy after it, with the dry delayed to
line up. Two IRs ship: a synthetic stereo hall and a bowed cymbal from
VSCO 2 CE (CC0), with a preset each. docs/46 describes the convolver and
its limits: the IR is built for 48 kHz, a swap doesn't crossfade, and the
partitions are uniform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h CONVO IR

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nooga

nooga commented Nov 5, 2026

Copy link
Copy Markdown
Owner

@mparrett thank you! I had to cherry pick, this is already on main with authorship preserved. Closing :)

@nooga nooga closed this Nov 5, 2026
@mparrett

mparrett commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@mparrett thank you! I had to cherry pick, this is already on main with authorship preserved. Closing :)

@nooga Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants