Spec 003 — The piano’s editor: a Play view for playing and watching, an Edit view for the model

Status

Written from the maintainer’s UI specification and decisions (2026-12-03). Orientation, not gospel: build a version that runs first, then change details, experiment with design decisions or add alternatives. The same holds for the model: it is fitted now, not hand-tuned; editing it later (better bass strings, hammer strike point …) extends the fit rather than contradicting Spec 001. The fixed Play shell is implemented in T-044.

Goal

The editor serves two jobs: playing the instrument while watching its response, and editing its physical model precisely enough to compare small changes. It is built with egui in the plugin’s window (ADR-0006), with the pinned egui version and the existing parameter and audio paths (T-025, T-016).

Decisions (maintainer, 2026-12-03)

Decision
ColourMonochrome throughout. Chromatic colour, if any, only for the clip warning, which keeps its CLIP label. T-020’s blue undamped bar becomes a monochrome mark.
NameThe library, bundle and host-visible plugin name stay Instruments / Instruments Piano (PLUGIN_NAME). Inside the opened editor the instrument is MathStruct Piano: a small math𝄞truct wordmark with Piano in a corner.
ThemeLight and dark. The choice is stored in the plugin state; until the user chooses, the editor follows the system setting where it can read one, else light. egui-baseview 0.9 does not fill egui’s RawInput::system_theme, so the plugin reads the OS setting itself, when the editor opens and off the audio thread (Linux: the org.freedesktop.appearance color-scheme portal setting; macOS and Windows: their appearance settings).

Visual identity

  • Editorial, monochrome. Following the MathStruct website (landing/src/styles/global.css, maintainer 2026-12-03): Light: paper #FAFAF9, raised controls #FFFFFF, ink #0B0B0B, secondary #636363, hairlines #E4E4E3/#CDCDCC. Dark: canvas #0A0A0A, raised #111111, ink #F4F4F3, secondary #9A9A98, hairlines #1F1F1F/#3B3B3B. Pill-shaped buttons and fields, the selected one solid ink; sliders as an ink track and knob on a light rail; section labels in small spaced-out monospace capitals; the theme switch a round sun/moon button. Contrast checked on the real widget surfaces. Whitespace and fine rules group controls; keyboard focus has an obvious outline.
  • Wordmark: the website’s math𝄞truct (landing/src/components/instruments/ClefWordmark.astro): Liberation Serif letters and Noto Music’s G clef (U+1D11E), both SIL OFL 1.1, as outlines; the editor rasterizes the same path data per display scale, so it matches the site exactly and loads no font. Small, in a corner, followed by a monospace label Piano · model.
  • Controls in a readable sans serif (~14 pt), tabular digits where practical.
  • The wordmark’s sources (Liberation Serif, Noto Music: both SIL OFL 1.1) ship with their licence notices, shown in the model/details panel with the model’s attribution.
  • Musical state is readable through geometry, marks and labels, never colour alone.

Window

RegionContents
HeaderWordmark in a corner, model (later: preset) name, Play and Edit tabs
PlayTuning, sound, output level, input status
EditScope (Instrument → Note → String), parameter search, override marks, inspector
Bottom dockPedal states above the A0–C8 keyboard, visible in both tabs
  • At the default 720 × 400 (T-020 D4) the core Play controls and the keyboard stay visible. The window is resizable (T-045: 480 × 360 to 2560 × 1600, kept per project): meters beside the controls and Microtuning on Play when wide; one column of controls, with the middle region scrolling on its own, when narrow; the keyboard fits the window’s width. The keyboard zooms to four or two octaves and then scrolls (T-046). In Edit the note list sits beside the inspector’s rows when standard or wide, a « » selector on the target line when narrow (T-047).
  • Switching tabs keeps the selected note, string and scroll positions.
  • The model’s name is in the header; version, source, fit provenance and licences (with the existing attribution) in a details popover or panel.

Play

  • Controls: A4 (440.00 Hz), String sustain (1.00 ×; today’s Sustain parameter, a multiplier on the strings’ decay, renamed so it does not read as the pedal; the id stays), Output gain (0.0 dB). Bounded sliders plus precise numeric entry, as T-020 already has. Spec 001’s later controls (hammer, soundboard, mics, resonance, noises) appear on Play when they are sound settings a player adjusts, and in Edit’s Instrument scope when they are model edits; the parameter table’s group decides, so no GUI code per parameter.
  • Meters: compact stereo, labelled L, R and dBFS; moving level and peak-hold marker distinguishable; a latched CLIP with a clear action (today: click). Labelled with what they measure (today: the plugin’s output after Gain).
  • Pedals: Sustain, Sostenuto, Soft side by side in the dock. Each shows Up / Down, a partial value only where the engine supports travel, and unsupported or no input distinctly from an observed Up. MIDI CC64, CC66, CC67 through the existing input path; the engine’s effective state where it reports one, else labelled as raw input. Since T-010 the engine supports all three and reports its state: Sustain and Soft show Up, Down or Half n % (CC64 and CC67 as travel), Sostenuto Up/Down; the half-pedal zone and the soft pedal’s depth are parameters in Resonance & noises (on Edit).
  • Keyboard: held = fill or inset, sounding = dot or intensity mark, undamped = thin bottom bar; the marks coexist on a key and come from distinct runtime states the engine reports (T-020 D1). A compact legend. In Edit, the selected note has its own outline.

Keys played from the editor (T-046)

Implemented in T-046.

T-020 D5 made the keyboard display-only. When it plays: black keys win overlapping hit tests; notes owned by the editor are released when a gesture ends outside the dock, focus is lost or the view changes; external MIDI stays independent (ownership rules of T-043). In Edit a click selects a note without sound, and a separate Audition action plays it. A note picker (name or MIDI number) works without the painted keyboard. External MIDI plays in both tabs.

Edit

The inspector is implemented in T-047 (Instrument and Note scopes; per-note edits are offsets on the fit that compose with the instrument value, D2). Microtuning (T-049) sits under the inspector on Edit since T-047 (above it, it filled the visible part of Edit at 720 × 400; a wide window shows it on Play too, T-045): the MTS-ESP switch with the connection status, and the Scala scale and mapping choosers. While a followed master or a Scala scale makes Play’s tuning controls ineffective, those are greyed there.

The inspector follows Instrument → Note → String and names its target explicitly (C4 · MIDI 60, later · String 2 of 3). Each parameter shows its scope.

  • Instrument: shared controls and defaults the engine exposes.
  • Note: note-level controls and a compact summary; the note list shows name, MIDI number and override status, and jumps by name or number. Hammer and damper controls belong here unless the model has them per string.
  • String: the selected string’s fields grouped by physical meaning (tuning and unison, losses and decay, dispersion, coupling), each with the model’s exact meaning and unit. Deferred: model format v2 has no physical strings: its string axis holds three fitted components per partial (prompt, slow, slow_partner; Piano model file), and no per-key string count. The String scope waits for a model with strings (coupled unisons, T-010); it must then handle string counts varying across the keyboard and a change of model.

Rows come from parameter metadata (T-025’s description, extended by scope): stable id, display name, scope, unit, range or validation rule, precision, step, help text, update behaviour. A row has label, precise value editor, unit, override mark, reset. Logarithmic only where the physical domain warrants it. Search over labels; a filter for modified values.

Overrides: where a value inherits (instrument → note → string) the row shows the effective value and its source; reset removes the local override and shows the inherited value. Elsewhere reset restores the loaded model’s baseline. An explicit override equal to the inherited value stays an override. Edits are offsets on top of the fit; the factory model stays identifiable.

Editing behaviour: widget ids and drafts keyed by model identity, note, string and parameter id. Validation errors next to the field, the draft kept, the engine keeps the last valid value. Enter commits, Escape restores. Changes that are costly get an explicit Apply and show as pending until accepted (none is costly today: T-016’s recompute takes milliseconds). One drag is one undo step where undo exists (in a plugin: the host’s, through T-025’s gestures).

Presets: saving a user preset keeps the factory model’s provenance. Per-note (later per-string) edits go into T-019’s state and preset format or a versioned extension keyed to model identity and stable ids; on load, incompatible targets are reported and compatible edits kept.

egui and audio

  • Native widgets for editable controls; custom painting for keyboard and meters. Interactive regions get labels and focus behaviour. egui-baseview 0.9 has no AccessKit bridge, so screen-reader names wait for one upstream; the labels are written now anyway.
  • Inspector in a ScrollArea; the note list (88 rows) virtualised if needed. Scroll regions have stable ids.
  • Meters, pedals and keys from a bounded telemetry snapshot (T-020’s EngineView); edits through the existing real-time-safe store. No formatting, I/O, allocation-heavy work or model rebuild on the audio thread; continuous slider updates coalesced; rebuilds validated and prepared on a worker and published through T-016’s swap. Changes to sounding notes follow the engine’s policy, and the editor shows when a change takes effect where that matters.
  • Repaint: ~30 fps while meters or key states move, a slow poll (~4 Hz) when idle, so no wake-up path from the audio thread is needed (refines T-020 D3).

Tasks

TaskBuildsDepends on
T-044Play shell at the fixed 720 × 400: theme (light/dark, system default, in state), wordmark, monochrome marks, Play/Edit tabs (Edit a placeholder), dock with the three pedal slots, String sustain label, meter labels, model details panel with font notices, idle repaintT-020
T-045Resizable editor (CLAP gui resize through baseview and hosts) and the responsive layouts aboveT-044
T-046Keys from the editor: a GUI note queue with ownership, Audition, note picker, select-without-sound in EditT-044, T-043
T-047Inspector, Instrument and Note scopes: a written override design (metadata with scope, per-key recompute, state keyed to model identity), note list, rows, reset and Apply semantics. String scope after T-010T-044, T-019

Verification (for each task, as far as it reaches)

Light and dark screenshots at 720 × 400, a wider size (after T-045) and one high-DPI run; logo spacing, focus outline, readable units, independent scrolling. Notes held and released under sustain; half-pedal values once they exist; a note with fewer strings than its neighbour once strings exist. Editing one target changes only that target; invalid input leaves audio unchanged; Apply stalls neither UI nor audio; older presets still load after a format change.