T-003 — Cargo workspace with the DSP crate and a first CLAP plugin on clack with an egui GUI
Status: done (manual DAW check done in Reaper, 2026-12-03) · Area: rust · Depends on: —
Read for that: Overview (layout), ADR-0001, ADR-0002, ADR-0006, Plugin formats (real-time rules), Testing and evaluation (gates). The crates’ own docs and examples at the versions you pin (AGENTS.md: no framework API from memory): clack-plugin, clack-extensions (both 0.2 on crates.io in Nov 2026; clack’s repository has plugin examples, including a GUI one), baseview, egui-baseview.
What: The skeleton every later task builds on. It proves the whole chain — workspace, DSP crate, CLAP plugin, GUI in the host window, bundling, validation — with a deliberately trivial sound.
- Workspace at the repository root:
Cargo.tomlwithresolver = "3",edition = "2024",rust-versionequal torust-toolchain.toml, memberscrates/*; shared[workspace.dependencies]; release profile withlto = "thin",codegen-units = 1. crates/dsp(library, no plugin dependencies): aProcessortrait in the shape of ADR-0002 (prepare(sample_rate, max_block),process(&mut self, events, outputs),reset()), and one implementation, a placeholder sine voice per held note with gain — clearly marked as a placeholder until the piano engine (T-008). Events carry a sample offset within the block. No allocation afterprepare.crates/piano(cdylib, the plugin that will become the piano): CLAP idio.github.danielboigk.instruments.piano, name “Instruments Piano”, featuresinstrument,stereo. Extensions:note-ports(one input, CLAP and MIDI dialects),audio-ports(one stereo output),params(one parameter, Gain in dB, smoothed),state(save/load parameters, with a version number),gui(egui through egui-baseview, embedded in the host’s parent window; one slider bound to Gain). GUI ↔ audio only through atomics; host automation updates the slider.crates/xtask:cargo xtask bundle piano [--release]→target/bundled/Instruments Piano.clap(Linux: the.sorenamed; macOS: the bundle directory withInfo.plist; Windows: the.dllrenamed).- Flake: add
clap-validator(not in nixpkgs as of Nov 2026: build it from source fromfree-audio/clap-validatorat a release tag, the same way as Graphicle inflake.nix) to the dev shells. - Tests:
dspunit tests (block-size independence with sizes 1, 64, 513; silence when no notes;assert_no_allocaroundprocessin debug tests).
Done when:
cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo nextest runpass in the dev shell.cargo xtask bundle piano --releaseproduces the bundle, andclap-validator validateon it passes.- The overview page and this page match what was built (crate names, commands);
docs/toolchainmentionsclap-validator. - Manual check by the maintainer (a cloud session has no DAW): load the bundle in a CLAP host on Linux (Bitwig or Reaper), play notes, move the slider, automate Gain, reopen the GUI. Note the result on this page.
Out of scope: CI (T-021), the model file (T-015), the piano engine (T-008).
Result (Nov 2026)
- Workspace:
crates/dsp(instruments-dsp),crates/piano(instruments-piano,cdylib),crates/xtask;.cargo/config.tomlaliasescargo xtask. Pinned majors: clack-plugin/-extensions 0.2, egui-baseview 0.9 (baseview 0.4, egui 0.37), clack-host 0.2 (tests). - DSP API as implemented (ADR-0002 updated):
Processor { prepare, reset, event, render, is_active }; the plugin renders up to each event’s sample offset (clack’s event batcher). The placeholderSineVoiceskeeps one state per key, as Piano 13 plans. - Plugin: note port (CLAP + MIDI dialects; MIDI note on/off and all-notes-off), stereo output, Gain (dB, −60…+6, smoothed 20 ms, automatable, gestures from the GUI reported to the host), versioned state (exactly
[1][f32 dB], five bytes; host told to rescan values after load), embedded egui editor (fixed size 420×160 logical, scaled bygui.set_scale). Processing sleeps when silent unless the editor is open (so GUI edits reach the host). - Gates: fmt, clippy (
-D warnings), 9 tests (4 DSP incl. block-size independence and no allocation; 2 parameter/state units; 3 in-process host tests). - clap-validator 0.4.1 on the release bundle: 44 tests, 35 passed, 0 failed, 9 skipped (all for optional extensions we don’t implement: preset discovery, 64-bit audio, configurable/activatable ports).
- GUI smoke test on Xvfb + Mesa llvmpipe (
scripts/gui-smoke-test.shin.#gui-test): editor embeds as a child of the parent X11 window, renders (title, note, slider), and is removed bydestroy. - Findings: egui 0.37 has no fonts unless the
default_fontsfeature is on (text rendered as boxes) — enabled in the workspace. Outside NixOS, Nix’s Mesa needsLIBGL_DRIVERS_PATHand__EGL_VENDOR_LIBRARY_FILENAMESset (baseview tries EGL first) — done in thegui-testshell. Editor errors are printed to stderr for the host’s log. - Not done here: the manual check in a DAW (no DAW in a cloud session).
- Since T-009 the plugin plays
PianoEngineinstead of the placeholderSineVoices(T-009); the plugin structure above is unchanged.
Fixes after review (Dec 2026)
Found in a review of the plugin code (issues #2–#5 on GitHub), fixed with tests:
- Zero-velocity note-on (
crates/dsp, PR #6):SineVoicestreats aNoteOnwith velocity ≤ 0 as a note-off. Before, such a key stayed active forever and the plugin never slept. The MIDI path already mapped0x90withdata2 == 0to note-off; CLAP note-ons with velocity 0 now behave the same. - Strict state decode (PR #7):
params::state::decodeaccepts exactly five bytes; trailing bytes are rejected. A longer format must bump the version, never extend version 1. - Gesture retry (PR #8):
sync_gestureonly records a gesture begin/end as reported oncetry_pushsucceeded, so a full output buffer delays the event to the next block instead of dropping it. - Host-change flag (PR #9): host-side gain changes made on the main thread (inactive
flush, state load) set a flag the audio thread takes, instead of the audio thread comparingf32values; the audio thread’s own write-back after automation (publish_gain_db) sets none.
Manual check (maintainer)
Load target/bundled/Instruments Piano.clap in Bitwig or Reaper on Linux; play notes; move the slider; automate Gain; close and reopen the editor; save and reload the project. Result (maintainer, Reaper on Linux, 2026-12-03, build of main after T-018): notes play; the editor opens, closes and reopens (T-020’s editor: grouped controls, keyboard with held/sounding/undamped marks, sustain-pedal state, meters); the controls change the sound; Gain automates; settings survive closing and reopening the project. Found: the Root menu showed A▯ because the editor’s font has no ♯/♭ (labels changed to C#, Eb …, test parameter_text_uses_characters_the_editor_font_has); Reaper’s preset menu lists no factory presets (only Reset to factory default), though clap-validator’s preset-discovery tests pass, so the preset check stays open for a host that browses CLAP presets (Bitwig). The first attempt loaded a stale pre-T-020 bundle: after rebuilding, clear Reaper’s CLAP cache and rescan.