Skip to content

Follow up on field keys: list the instruments, add juno and bass, rename the pad, and keep the notes last - #183

Merged
ninjudd merged 6 commits into
mainfrom
keys/follow-up
Oct 11, 2026
Merged

ninjudd merged 6 commits into
mainfrom
keys/follow-up

Conversation

@ninjudd

@ninjudd ninjudd commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Trying the keyboard instrument after #178 to #182 merged turned up five things, and this pull request collects the fixes from that testing.

First, field keys bass in examples/bloom printed only that shared/instruments/bass.scd did not exist, which leaves you guessing at what the names are. A name that is not on the shelf now lists what is there, split into the instruments that play from notes and those that only render. The split reads each program's text for FIELD_MODE: a program that never reads it cannot answer voice mode, so its text is enough to tell, without starting sclang once per program. Directories and files that are not .scd are left out. Outside a project, a bare name still fails as before, because there is no shelf to list.

Second, still-water-pad was the only instrument you could play. examples/bloom now has two more, juno and bass, both the JU-06A from okamnesiac/offset (patches/ju06a.scd), a model of the Roland Juno's chain: DCO (saw, pulse, sub, noise), high-pass, resonant low-pass, VCA, and a BBD-style chorus under one ADSR. juno is set to offset's classic Juno pad from sessions/juno.scd, and bass to the bass that patch's factory makes, which is the bass synth we built there. Each answers FIELD_MODE=voice with a SynthDef under the voice contract, at true pitch, and otherwise renders a short demo under the sc-render contract, so it also works as a supercollider: source: juno a held C minor ninth, bass offset's line. Each program carries its own copy of the graph, because a program's bytes are the cache key for what it renders, and a shared file loaded at run time would not re-key the renders that used it.

Third, still-water-pad is now pad, so field keys pad reads like field keys juno and field keys bass. Its SynthDefs are padKey and padVoice, and with seed 90210 and 10 s it renders the same bytes still-water-pad.scd did on main. The pad-sc track, both READMEs, the docs, and the plan follow; the plan's verification rows keep the old name, because the runs used it.

Fourth, playing moved the status line around: the notes sat in the middle, so everything after them shifted with every key. The notes are last now, and a narrow terminal shortens the text before them, never the notes. The Playing … Esc or Ctrl-C quits. line is gone, and an instrument's state, such as juno live at 48000 Hz on MacBook Pro Speakers, has the first line to itself, redrawn in place only when it changes.

Fifth, the keymap reload test failed now and then under load. A watch just started can lose a directory event outright, not only see it late, so the test saves again every 500 ms until each reload arrives; a save of text already loaded reloads nothing, so a repeat never adds one. Sixteen concurrent runs of the file pass.

docs/keys.md shows the new listing and names the three playable instruments.

Testing

From the repository root of this branch, after pnpm install, with SuperCollider installed:

pnpm typecheck
pnpm exec vitest run src/keys/voice-host.test.ts src/keys/keymap.test.ts
cd examples/bloom
../../node_modules/.bin/tsx ../../src/cli.ts keys organ
../../node_modules/.bin/tsx ../../src/cli.ts sc render shared/instruments/juno.scd --seed 1 --duration 4 --output /tmp/juno.wav
../../node_modules/.bin/tsx ../../src/cli.ts sc render shared/instruments/bass.scd --seed 1 --duration 4 --output /tmp/bass.wav

The typecheck passes, and the two test files pass 25 of 25. A program named like pad.v2.scd lists under that whole name, which field keys resolves. The keys organ command exits 1 and prints:

field keys organ: no instrument program at …/examples/bloom/shared/instruments/organ.scd
In shared/instruments/:
  plays from notes: bass, juno, pad
  renders only:     creek-kit, seven-eight-loop (no FIELD_MODE=voice branch; Field's docs/keys.md says how to add one)

juno or bass under "renders only", or no list at all, would mean the change is wrong. Each render writes a 4-second stereo WAV; I measured the chord at a -5.5 dBFS peak and the line at -9.4 dBFS, and a second render with the same seed was byte-identical, in stereo and mono. A clipped or silent file would mean the program is wrong. The renders are left in /tmp.

To play them, from examples/bloom in Ghostty or iTerm2, run field keys juno or field keys bass, with field built from this branch. I could not listen here. In voice mode I rendered a recorded take of two notes through each, through field build of a record entry with that instrument: both sounded from the first note, peaked near -10.5 dBFS, and fell silent one release time after the last note-off (1.5 s for juno, 0.15 s for bass), so every voice frees itself.

The status line is covered by src/commands/keys.test.ts. I also ran field keys and field keys juno in a pseudo-terminal that answers the keyboard protocol: the first drew only the status line, ending · C4 E4 while two keys were held; the second drew juno starting above it, then rewrote that line in place to juno live at 48000 Hz on MacBook Pro Speakers. In a real terminal, the start of the status line should stay still while you play; anything after the notes, or a second status line, would mean the drawing is wrong.

I also ran the full suite with FIELD_AUDIOD pointed at a native build: 932 passed, 1 skipped (the no-MIDI-source case, which runs only without a MIDI service).

📽️ Projector summary of cdcccaa: https://field.amnes.ac/reviews/183

field keys bass in examples/bloom said only that bass.scd was missing, which leaves you guessing at names. A miss now lists the shelf, split into the programs that play from notes and those that only render, by whether each reads FIELD_MODE: a program that never reads it cannot answer voice mode, so its text tells without starting sclang for each.
… from field keys

Both are the JU-06A model from okamnesiac/offset (patches/ju06a.scd), the Roland Juno's DCO, HPF, resonant VCF, VCA, and chorus under one ADSR. juno is set to offset's classic Juno pad and bass to the bass its factory makes. Each answers FIELD_MODE=voice with a SynthDef under the voice contract, at true pitch, and otherwise renders a short demo under the sc-render contract: juno a held C minor ninth, bass offset's line from sessions/juno.scd. Each program carries its own copy of the graph, because a program's bytes are the cache key for what it renders. docs/keys.md names them, and its example of a missing name is now organ.
Each reload waits up to 5 s, but vitest's default 5 s covered the whole test, and on a loaded machine file events can arrive a second or more late; the full suite timed it out twice. The test now has 20 s.
@ninjudd ninjudd changed the title List the instruments field keys can play when a name is not on the shelf Follow up on field keys: list the instruments on a miss, and add juno and bass to examples/bloom Oct 11, 2026
field keys pad reads better beside juno and bass. The program's SynthDefs are padKey and padVoice; with seed 90210 and 10 s, pad.scd renders the same bytes still-water-pad.scd did on main. The pad-sc track, both READMEs, the docs, and the plan follow; the plan's verification rows in §10.3 and §13.3 keep the old name, because the runs used it, and §13.2 says so.
@ninjudd ninjudd changed the title Follow up on field keys: list the instruments on a miss, and add juno and bass to examples/bloom Follow up on field keys: list the instruments on a miss, add juno and bass, and rename still-water-pad to pad Oct 11, 2026

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ Projector review · 0.7.3 · model claude-opus-5-5 · effort xhigh · CHANGES REQUESTED · took 19m 46s over 3 heads

This pull request collects fixes from trying the keyboard instrument after #178 to #182. When field keys <name> names a program that is not on the project's shared/instruments/ shelf, the error now lists the shelf, split into programs that play from notes and programs that only render, by whether each program's text mentions FIELD_MODE. examples/bloom gains two playable instruments, juno and bass, both ports of the JU-06A synth from okamnesiac/offset, and renames still-water-pad to pad everywhere but the plan's records of past runs. The keymap reload test gets a 20 s budget for its three reloads. The branch is meant to collect further fixes from the same testing.

1 finding thread: 0 resolved, 1 open

Covered 12 of 12 changed files; no generated files.

  • The head moved twice during the review. It started at e147fe9, moved to f74396c, and then to 8447be4. I checked every finding again at 8447be4, and every number below comes from 8447be4 unless it names another head.
  • The new instruments were read, not rendered. This review does not start sclang or scsynth. So I checked juno.scd and bass.scd by reading them against the voice and render contracts in docs/keys.md and docs/build-graph.md, and against offset's patches/ju06a.scd and sessions/juno.scd. Their knobs match offset's "Classic Juno pad" and the ~ju06a factory's bass, and the graph matches offset's stage by stage.

Suggestions

  • The reload test still fails at this head. src/keys/keymap.test.ts:120: of eight concurrent runs of this file, three failed with no reload 1 within 5 s, which is nextReload's own deadline, so the 20 s budget cannot help them. The first save's directory event is sometimes lost rather than late, because the test saves right after watchKeymap starts the watch. Under four parallel processes, 4 of 60 first reloads never arrived within 30 s, and every other reload arrived within 85 ms. The same race is at the base. Re-save the first edit every 500 ms until reload 1 arrives. Under the same load, one re-save recovered each of the 4 lost events, within 605 ms.
  • "Press Z" holds only in the default keymap. docs/keys.md:169: tracker and fourths bind Z to a note and transpose on the arrows. Say "in musical-typing", as bass.scd's own comment does.
  • The message points at a file the user's project does not have. src/commands/keys.ts:67: see docs/keys.md is a path in Field's checkout, but the message prints in the user's project, and bloom has no docs/ directory. No other runtime message names a docs path. Point at "Make an instrument playable" in Field's docs/keys.md, or drop the pointer.
  • shelfInstruments needs no export. src/commands/keys.ts:46: nothing outside keys.ts imports it, and the test reaches it through resolveInstrument. Drop the export until a caller needs it.
  • The docs misstate when .scd is added. docs/keys.md:85 says a name works "with or without .scd", and docs/project-model.md:354 says "a name without .scd gets it". instrumentProgram adds .scd only to a name with no extension, so pad.v2 never names pad.v2.scd. This is already true at the base. State the rule as keyboard-instrument.md §2.1 does: .scd is added to a name that has no extension.

What I ran

All of these ran in a scratch worktree at 8447be4, after pnpm install --frozen-lockfile.

  • pnpm typecheck. Passes.
  • pnpm exec vitest run src/keys/voice-host.test.ts src/keys/keymap.test.ts. Three sequential runs passed 25 of 25. At f74396c, the same command failed once in eight sequential runs and once in eight concurrent runs, the second time in the reload test.
  • field keys organ in examples/bloom. Exits 1 and prints exactly the listing docs/keys.md shows.
  • node ../../dist/cli.js check in examples/bloom, the step CI runs. Prints ok with pad-sc pointing at pad.scd.
  • resolveInstrument against a project whose shelf holds only pad.v2.scd. Lists pad.v2, and pad.v2 then fails, as the thread describes.
  • watchKeymap alone, 60 runs under load, timing the first reload, with and without a re-save. The numbers are in the first suggestion.

Outside a project, a bare name still fails before any listing, and a path still resolves from where you are. An empty or missing shelf prints shared/instruments/ has no programs yet.. Directories named *.scd and Emacs's dangling .#name.scd lock links are left out because Dirent.isFile() is false for both, and files that do not end in .scd are left out by name. After the rename, no file names still-water-pad except the plan's §10.3 and §13.3 rows and the note that says they keep it.

Comment thread src/commands/keys.ts Resolved
…s own line, and list dotted programs by a name that resolves

Playing moved everything after the notes, so the notes are last now, and a narrow terminal shortens the text before them instead of the notes. The Playing ... Esc or Ctrl-C quits line is gone. An instrument's state has the first line to itself, redrawn in place only when it changes, so the status line holds the session and the notes.

From the review of #183: the listing keeps .scd on a program whose name has another extension, so pad.v2.scd lists as a name field keys resolves. The reload test saves again every 500 ms until each reload arrives, because a watch just started can lose a directory event outright; sixteen concurrent runs pass. The listing's pointer names Field's docs, shelfInstruments is no longer exported, and the docs say .scd is added to a name with no extension and that Z drops an octave in musical-typing.
@ninjudd ninjudd changed the title Follow up on field keys: list the instruments on a miss, add juno and bass, and rename still-water-pad to pad Follow up on field keys: list the instruments, add juno and bass, rename the pad, and keep the notes last Oct 11, 2026

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ Projector review · 0.7.3 · model claude-opus-5-5 · effort xhigh · CLEAN · took 3m 48s

This pull request collects fixes from trying the keyboard instrument after #178 to #182. When field keys <name> names a program that is not on the project's shared/instruments/ shelf, the error lists the shelf, split by whether each program's text mentions FIELD_MODE. examples/bloom gains two playable JU-06A instruments, juno and bass, and renames still-water-pad to pad. Since the last review, the status line ends with the sounding notes, and an instrument's state has its own line above it. The reload test now saves again until each reload arrives, and the listing names a dotted program by a name that resolves.

1 finding thread: 1 resolved, 0 open

Covered 13 of 13 changed files; no generated files. Since the review of 8447be4, src/commands/keys.ts, src/keys/keymap.test.ts, src/keys/voice-host.test.ts, the new src/commands/keys.test.ts, docs/keys.md, docs/project-model.md, and the keyboard-instrument plan changed. I read each of them in full at 8b9718d. The six files that did not change keep that review's reading.

  • The new instruments were read, not rendered. This review does not start sclang or scsynth, so juno.scd and bass.scd stand on the earlier reading against the voice and render contracts and offset's sources. Neither file changed since then.
  • The new drawing was read, not watched. This review does not open an interactive field keys, so the two-line drawing was checked by reading draw and by the new statusText tests.

Suggestions

  • Acceptance criterion 25 still looks for the instrument on the status line. docs/projects/keyboard-instrument/readme.md:658 says "the status line shows the instrument restarting and then live at 48 kHz". The state now has its own line above the status line, as §2.1 step 6 and §2.4 already say. Name the instrument's line there, unless you keep the chunk 2 rows as they were run.
  • "Never the notes" holds until the notes alone are wider than the terminal. src/commands/keys.ts:248 and docs/keys.md:58 promise the notes are never shortened, but when they alone pass the width, statusText returns notes.slice(0, width). That takes about 20 held keys on an 80-column terminal, so it is rare. Say "never the notes unless they alone are wider than the terminal", or keep the claim and accept the edge.

What I checked

All of this ran in a scratch worktree at 8b9718d, after pnpm install --frozen-lockfile.

  • The earlier finding is fixed. shelfInstruments now keeps .scd on a program whose stem still has an extension. Against a scratch shelf, pad.v2.scd lists as pad.v2.scd, a.scd.scd as a.scd.scd, and .hidden.scd as .hidden, and resolveInstrument accepts each listed name. The thread was already resolved, so it needs no reply.
  • The reload test no longer fails under load. 32 runs of src/keys/keymap.test.ts, eight at a time, all passed, where 3 of 8 failed at 8447be4. At least 5 of the 32 took over 500 ms, so they reached the re-save and recovered through it. A re-save cannot add a reload, because watchKeymap ignores text it already loaded.
  • pnpm typecheck. Passes.
  • pnpm exec vitest run src/commands/keys.test.ts src/keys/voice-host.test.ts src/keys/keymap.test.ts. 27 of 27 pass.
  • field keys organ in examples/bloom. Exits 1 and prints exactly the listing docs/keys.md shows, with the new pointer to Field's docs/keys.md.
  • node ../../dist/cli.js check in examples/bloom, the step CI runs. Prints ok.
  • The two-line drawing. Only draw writes to the terminal while you play, because the helper and the voice host both run with piped output. So the cursor is always on the status line when draw moves up one line to rewrite the instrument's line. draw gives statusText the terminal's width less one column, at least 20, and statusText keeps the line within it, so the status line does not wrap on any terminal 21 columns or wider.
  • The earlier suggestions. The message names Field's docs/keys.md, shelfInstruments is no longer exported, docs/keys.md says Z drops an octave in musical-typing, and docs/keys.md and docs/project-model.md state that .scd is added to a name with no extension, which is what instrumentProgram does.

@ninjudd
ninjudd marked this pull request as ready for review October 11, 2026 03:59
…re shortened

From the clean review of #183. Criterion 25 looked for the instrument's restart on the status line, which no longer carries it. The status line shortens the notes too once they alone are wider than the terminal, about twenty held keys at 80 columns, so the comment and docs say that instead of never.

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ Projector review · 0.7.3 · model claude-opus-5-5 · effort xhigh · CLEAN · took 0m 48s

This pull request collects fixes from trying the keyboard instrument after #178 to #182. When field keys <name> names a program that is not on the project's shared/instruments/ shelf, the error lists the shelf by names that resolve, split by whether each program's text mentions FIELD_MODE. The status line ends with the sounding notes, and an instrument's state has its own line above it. examples/bloom gains two playable JU-06A instruments, juno and bass, and renames still-water-pad to pad. The keymap reload test saves again until each reload arrives. Since the clean review of 8b9718d, this head changes only prose, taking that review's two suggestions.

1 finding thread: 1 resolved, 0 open

Covered 13 of 13 changed files; no generated files. Since 8b9718d, three files changed: a comment in src/commands/keys.ts, one sentence in docs/keys.md, and criterion 25 in the keyboard-instrument plan. I read each against the code at cdcccaa. The other ten files are unchanged since the review of 8b9718d, and that reading stands.

  • The new instruments were read, not rendered. This review does not start sclang or scsynth, so juno.scd and bass.scd stand on the earlier reading against the voice and render contracts and offset's sources.
  • The two-line drawing was read, not watched. This review does not open an interactive field keys.

What I checked

All of this ran in a scratch worktree at cdcccaa, after pnpm install --frozen-lockfile.

  • The new comment and doc sentence match statusText. It returns notes.slice(0, width) only when the notes and the separator leave no room for the text before them. The slice shortens the notes only when they alone are longer than the width. So "the notes only when they alone are wider than it" holds.
  • Criterion 25 names the instrument's line. That matches draw, which writes the instrument's state on its own line above the status line, and matches §2.1 step 6 and §2.4 of the plan.
  • No code changed. The only .ts change since 8b9718d is the comment above statusText.
  • pnpm typecheck. Passes.
  • pnpm exec vitest run src/commands/keys.test.ts src/keys/voice-host.test.ts src/keys/keymap.test.ts. 27 of 27 pass. The reload test is unchanged since 8b9718d, where 32 runs of it, eight at a time, all passed.
  • field keys organ in examples/bloom. Exits 1 and prints exactly the listing docs/keys.md shows.
  • node ../../dist/cli.js check in examples/bloom, the step CI runs. Prints ok.
  • The one finding thread. The dotted-name finding from 8447be4 stays fixed at this head, because the listing code has not changed since 8b9718d verified it. Its thread is resolved.

@ninjudd
ninjudd merged commit 54f36d3 into main Oct 11, 2026
1 check passed
@ninjudd
ninjudd deleted the keys/follow-up branch October 11, 2026 04:10
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.

1 participant