T-020 — The piano’s editor: every parameter as a control, a keyboard with key and damper state, output meters, the model and its licence

Status: done (maintainer looked at the screenshot and the editor in Reaper, 2026-12-04) · Area: rust · Depends on: T-009, T-025

Read for that: Spec 001 (GUI (draft)), T-025 (the description and store the editor reads), ADR-0006, Plugin formats (audio-thread rules), T-009 (D4: attribution), crates/piano/src/{gui,audio}.rs, crates/dsp/src/piano/{engine,key}.rs, scripts/gui-smoke-test.sh.

Why: the editor shows only Gain and the attribution; Sustain and A4 are reachable only through a host’s generic view, and nothing shows what the engine is doing.

Scope (maintainer, 2026-12-02): controls for the parameters that exist (Gain, Sustain, A4), a keyboard view, meters, the model and its licence. Spec 001’s other controls are added by the tasks that create them; because the editor is built from T-025’s table, adding a parameter there adds its control.

What

  1. Controls from the table: one section per group, in Spec 001’s order (Tuning, Hammer, Strings, Soundboard & mics, Resonance & noises, then Output); empty groups are not shown. Each control is a slider per the description (range, Scale::Log → logarithmic slider, decimals, unit), double-click resets to the default, the value can be typed (T-025’s parse); GUI edits and gestures go through the store, per parameter.
  2. Keyboard: 88 keys, A0–C8, drawn by egui; each key shows held (key down), sounding (modes active) and undamped (damper lifted: held, or pedal down, or no damper in the model); a pedal indicator.
  3. Meters: one peak meter per output channel, dBFS, −60 … +6, with peak hold and a clip mark above 0 dBFS.
  4. Model: its name, version and the attribution line CC BY requires (as T-009 D4), and the licences of data and fit (ADR-0007).
  5. Pages: Spec 001’s GUI (draft) points to this page for what exists.

Decisions (accepted by the maintainer, 2026-12-02)

QuestionOptionsProposal
D1How key state reaches the editor(a) an EngineView of atomics written by the audio thread once per block: three 88-bit sets (held, sounding, undamped) as [AtomicU64; 2] each, plus the pedal as an AtomicBool; relaxed stores, no allocation; the engine gets a read-only accessor for its key states and pedal (crates/dsp); (b) a ring of note events replayed in the editor(a): a snapshot is enough for a display (≤ one block late), costs ~7 stores per block, and cannot overflow
D2How levels reach the editor(a) per channel an AtomicU32 holding the block’s peak as f32 bits, merged with fetch_max (valid for non-negative floats) by the audio thread and taken with swap(0) by the editor each frame; ballistics in the editor: hold 1.5 s, fall 20 dB/s; clip mark held until clicked; (b) RMS on the audio thread(a): one atomic per channel per block; peaks between frames are never lost
D3Repaint(a) while the window is open, repaint every 33 ms (request_repaint_after), so meters and keys move without host events; (b) repaint only on change(a): ~30 fps of a small egui window is cheap; (b) needs a wake-up path from the audio thread
D4Size(a) fixed 720 × 400 logical pixels, the keyboard across the bottom; (b) resizable(a): resizing through baseview and every host is a task of its own
D5Playing from the editor’s keyboard(a) not in this task (display only); (b) clicks send notes to the audio thread through a queue(a): a note queue from the GUI is a second event source with its own ownership rules (T-043)

Out of scope: controls for parameters that do not exist yet, resizing, presets (T-019), settings files (T-030), playing from the editor.

Done when: the gates of AGENTS.md pass including the GUI smoke test; unit tests cover the bit sets (all 88 keys, pedal), the meter ballistics and the table-driven layout (every table entry gets exactly one control, groups in order); no_alloc passes with the view and meters written; a screenshot of the editor while a chord sounds is attached to this page’s outcome; the maintainer has looked at it.

Outcome

  • The editor shows A4 under Tuning, Sustain under Strings, and Gain under Output. The table supplies each slider and editable value. Double-click a slider rail to reset it.
  • The display-only keyboard shows held, sounding and undamped keys alongside the sustain pedal state. Each output meter shows dBFS and peak hold. Click the meter to clear its clip indicator.
  • The model line gives salamander-c5 version 2026-12-02, the CC BY 4.0 fit licence and the Salamander Grand Piano V3 attribution (Alexander Holm, CC BY 3.0).
  • Undamped is a blue bar across the foot of the key (first drawn as a faint grey bar; made visible after the maintainer saw the first screenshot).
  • The image is the X11 smoke test’s capture (GUI_SMOKE_PPM): the editor embedded in a host window while a pedalled chord plays, two keys of it released. Gates: fmt, clippy, nextest (124 passed, 1 skipped: the X11 test, run by the smoke test), clap-validator (35 passed, 9 skipped), GUI smoke test passed.
  • Implemented by Codex; reviewed by Mistral (defects only, probes in a scratch worktree). Triage: no verified defect. Bit sets (index = MIDI − 21 across both words, C8 = 87, no bits above 87, undamped = not (damper and not held and not pedal)), peak merging (NaN dropped, −0.0, ±∞, mono), meter ballistics, no_alloc, gestures (drag, reset, typed value, parse failure, gesture closed on drop) all probed and passed. One latent note — a table entry whose group is not one of the six names would get no control — is already caught by layout_has_one_control_per_parameter_in_spec_order, which runs on the real table and checks every id; no change.