Authoring a Built-in Device (Bakery Playbook)
The built-in instruments and effects are the bread-named modules — Fermenter (synth), Toaster (drums), Gluten (compressor), and so on. The built-in device set is defined in code, not in prose: the built-in devices are described by descriptors (most in their own <Device>Descriptor.ts under src/modules/Arrangement/models/PluginDescriptors/), and BUILTIN_PLUGINS in src/modules/Arrangement/models/DeviceParameter.ts aggregates them. Separately, src/modules/AudioEngine/engine/wasmDeviceRegistry.ts lists the devices with an async WASM engine. Devices share a repeatable anatomy across four surfaces: a TypeScript module, a Rust DSP engine, an AudioEngine node, and a panel registration. This document is the playbook for adding a new one or changing an existing one.
It complements:
TypeScript Module Architecture— module anatomy and contract barrelsWASM DSP Pipeline— how engines reach the workletcrates/daw-dsp/AGENTS.md+src/modules/AudioEngine/AGENTS.md— subtree rules
1. Anatomy of a device
| Surface | Location | Responsibility |
|---|---|---|
| TS module | src/modules/<Device>/ | patch state, telemetry, panel UI, use cases |
| Rust engine | crates/daw-dsp/src/<device>/ | sample-level DSP, dual-compiled native + WASM |
| Engine node | src/modules/AudioEngine/engine/<Device>Node.ts | wraps the WASM instance as a graph node |
| Panel wiring | WorkspaceShell device panels + the device's <Device>Descriptor.ts | how the UI opens and what parameters exist |
Not every device has every surface. Yeast (MIDI FX) and CvGate are TS-side only; the Tuner is the scoring crate; ProofChamber is its own proof-chamber crate; Crumbs adds a desktop-only native path (repositories/crumbsBridge/) beside its WASM engine. Read the sibling module's own AGENTS.md and its entry in wasmDeviceRegistry.ts before copying its shape.
2. TypeScript module conventions
Store shape. Multi-instance devices key state by deviceId: createStore<Record<string, DeviceState>>. The store is a public read contract — all writes go through the module's own use cases or executeAppAction.
Telemetry split. Meter data (~60 Hz) must not live in the patch store — rewriting the patch map at meter rate would churn persistence and undo. Follow Gluten: glutenStore (patch) vs glutenMeterStore (telemetry). Telemetry is a side channel, never truth.
Styling. One stylesheet per styled device in src/styles/utilities/modules/<device>.css; components come from the shared src/components/daw/ family (Fader, RotaryKnob, LED, Daw* panels, DSP-curve visualizers).
Naming. Module PascalCase matching the bakery name; the Rust engine is the snake_case twin (GrandBoule ↔ grand_boule). Device-panel events use the generic panel.showDevice; per-device panel events are deprecated.
3. Rust engine conventions
One module per device under crates/daw-dsp/src/, with a #[wasm_bindgen] <Device>Instance struct unless the device is native-only. The audio path is allocation-free and lock-free, enforced by assert_no_alloc dev-dependency tests — they are the RT contract, and they fail if you allocate in a process path. Code must compile for both native and wasm32; gate platform-specific bits with cfg.
After changing an engine's WASM surface, rebuild with pnpm wasm:dsp (or wasm:all) so the worklet glue in AudioEngine/wasm/ regenerates — never hand-edit generated glue.
4. Wiring checklist for a new device
- TS module with store (patch/telemetry split) and use cases. Add a
handlers/map exported viaget<Device>Handlers()only if the device owns its ownAppActions (GrandBouledoes); ordinary parameter edits go through the genericsetDeviceParameteraction. - If the device has a handler map, add it to
src/app/getProductionCommandHandlerMaps.ts.src/app/__tests__/bootstrap.spec.tspins which maps register and in what order; update the spec. - Rust engine in
crates/daw-dsp/+*Instanceexport; add to the workspace if new. - Engine node in
AudioEngine/engine/viawasmDeviceRegistry.ts; the engine node runs the worklet init handshake throughsrc/infra/audioWorklet/workletInitShared.ts. - A
<Device>Descriptor.tsinArrangement/models/PluginDescriptors/, listed inBUILTIN_PLUGINS(Arrangement/models/DeviceParameter.ts), so automation and generic inspectors see it. - Panel view under the module's
presentations/viewsbarrel; route throughpanel.showDevice. - Stylesheet in
src/styles/utilities/modules/. - Specs: one per source file in
__tests__/, pertesting-file-layout.
Skip a step and something degrades silently: a parameter write outside executeAppAction → no undo entry; no telemetry split → 60 Hz undo churn; no descriptor → invisible to automation; wrong init path → worklet never becomes ready.
5. Study these first
- Gluten — the cleanest small effect: store split, engine, node, panel.
- Crumbs — the desktop-native exception: a
repositories/crumbsBridge/mirror of an engine that runs natively on desktop. - ProofChamber — the separate-crate exception (reverb as
proof-chamber, "Dutch Oven" device id).
References
BUILTIN_PLUGINSinsrc/modules/Arrangement/models/DeviceParameter.tsand the<Device>Descriptor.tsfiles insrc/modules/Arrangement/models/PluginDescriptors/— the built-in device setsrc/modules/AudioEngine/engine/wasmDeviceRegistry.ts— the devices with an async WASM enginedocs/architecture/07-wasm-dsp-pipeline.md— build and loadingdocs/06-testing.md— spec layout