Skip to content

Type a knob's value on the number row and glide it there, and quit field keys on Ctrl-C alone (instrument-knobs.md chunk 2) - #210

Merged
ninjudd merged 4 commits into
knobs/turnfrom
knobs/type
Oct 11, 2026
Merged

ninjudd merged 4 commits into
knobs/turnfrom
knobs/type

Conversation

@ninjudd

@ninjudd ninjudd commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Turning a knob from one end of its range to the other takes about 2.3 seconds of holding an arrow, and landing on a particular value means watching the line and letting go in time. This second chunk of the instrument-knobs plan (#202) lets you type the value instead. In musical the number row types the chosen knob's value, in the units its knob file names, so 800 on cutoff means 800 Hz and 0.8 on attack means 800 ms. Enter completes it, and the knob glides to the controller value nearest the number, since a controller carries only 128 values: 800 lands on 810 Hz.

The glide is a run of control changes, one every 40 ms at most, at a speed the keymap's new glide field sets: the seconds a value takes to cross a knob's whole range. musical sets one second, and a keymap that never mentions glide sets a typed value at once. Because the glide is MIDI, a take keeps it and any instrument answers it, which a longer lag inside the instrument could not do.

. was the bend up's key in chunk 1, so Period types the decimal point only while a value is open, as #202 recommended and Justin merged. With no value open it still bends, which is why a value cannot start with .. Backspace edits a value, and a knob key completes it first, the way moving off a cell completes it in a spreadsheet. Notes keep playing while you type, so you can type over a held chord.

Esc now cancels a value instead of quitting, and with no value open it puts Ctrl-C quits on the status line. Ctrl-C alone quits, and no keymap can bind Esc or a Ctrl chord, so no keymap can trap you still. This amends keyboard-instrument.md §2.4, which now carries a dated note pointing at the plan. Enter, Backspace, and Escape are positions the session handles before the keymap, from the kitty protocol's CSI 13 u, CSI 127 u, and CSI 27 u.

This stacks on #209. §10 of the plan records what implementation settled.

Testing

I ran these on macOS, from the root of a checkout of this branch unless a step says otherwise, after building as #209's Testing section does (pnpm install, pnpm build, pnpm build:native).

  1. pnpm typecheck prints nothing and exits 0.
  2. pnpm vitest run reports 90 test files, 1191 tests passed and 1 skipped. A failure in src/keys/session.test.ts's "typing a knob's value" tests, src/commands/keys.test.ts's "typing on the knob line", or src/keys/terminal.test.ts's quitting tests points at this change.
  3. From examples/bloom, node ../../dist/cli.js keys --print draws musical with 1 to 0 and - on the number row and lists each as type <c> into the chosen knob's value.

I also drove field keys --knobs in a pseudo-terminal, sending the kitty protocol's bytes, against a stand-in for field-audiod --keys that logs every message it is sent and publishes no MIDI source. The knob file had juno's cutoff and attack. What it showed:

  • 800 read cutoff 800_ Hz, and Enter glided CC 74 from 82 down to 62, five values a tick, to 810 Hz (criterion 4).
  • 12, Backspace, 5 read 15_ Hz. The first Esc closed it and left 810 Hz, the second put Ctrl-C quits on the status line, and Ctrl-C quit with All Notes Off (criterion 6).
  • 300 and ArrowRight glided to 301 Hz and moved the choice (criterion 7).
  • 0, ., 8 read 0.8_ s and landed attack on 782 ms, and . with the value closed sent a bend up and its release (criterion 23).
  • At most 5 control changes went out in any second.

The stand-in is a 15-line Node script that prints {"ready":true,"name":"Field Keys"} and appends each line it reads to a log; point FIELD_AUDIOD at it to repeat the run without a MIDI source.

What I could not run is anything by ear or in a real kitty terminal: criteria 4 to 8, 12, 14, 18, and 23 by hand. From examples/bloom in Ghostty or iTerm2, run node ../../dist/cli.js keys juno, hold a chord, choose cutoff, type 800, and press Enter. The filter should close over about half a second while the line runs down to 810 Hz. A line that jumps straight there means glide did not load from musical, and a chord that stops when you type means the number row is still playing notes.

📽️ Projector summary of cd79e60: https://field.amnes.ac/reviews/210

@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.7 · model claude-opus-5-5 · effort xhigh · CHANGES REQUESTED · took 14m 11s over 2 heads

This is chunk 2 of the instrument-knobs plan. In musical, the number row types the chosen knob's value in its knob file's units. Enter completes the value, and the knob glides to the nearest of its 128 controller values at the keymap's new glide speed, one control change per 40 ms tick. Period types the decimal point only while a value is open, and Esc cancels a value instead of quitting, so Ctrl-C alone quits. Chunk 3, which covers .field/keys.json, the daemon's chase, and criteria 20 and 21, is left for later. The criteria that need a kitty terminal and sound (4 to 8, 12, 14, 18, and 23) are recorded as still owed in §10.3.

1 finding thread: 0 resolved, 1 open

Covered 20 of 20 changed files; 0 generated files skipped.

The head moved from f95a11e to 78525ef during this review, when #209 gained 6a7f2a2, a fix to src/keys/knobs.test.ts's expected paths on Windows. git range-diff shows this pull request's commit unchanged, and every line this review cites reads the same at 78525ef.

This head was reviewed by reading, without running its code. The commit's git author and committer are ninjudd. Its Co-Authored-By: Claude <[email protected]> trailer, though, makes GitHub list a second author login, claude, which has only read permission on this repository. Projector's trust rule withholds trust from a head whose commit names a login without write access. So this review ran no pnpm install, pnpm typecheck, or vitest. project review setup printed "trusted" because it checks only each commit's git author, not its co-authors. project check, which is Projector's own tool reading the plans, passes at this head.

CI ran the head's code instead, and passed at 78525ef:

  • linux. pnpm typecheck, pnpm build, field check in examples/bloom, and pnpm test passed: 1159 tests, with 29 skipped. At f95a11e it had failed src/keys/voice-host.test.ts:272, which waits at most 2 seconds for a stub sclang's second reload status. This change touches neither that test nor src/keys/voice-host.ts, and the test passes here, so that failure was a timing flake.
  • windows. pnpm test passed 1056 tests, with 132 skipped. At f95a11e it had failed the two tests that #209's run failed: the --knobs path test that 6a7f2a2 fixes, and a src/release.test.ts timeout.
  • This chunk's tests. session.test.ts (43), commands/keys.test.ts (19), schema/keymap.test.ts (18), terminal.test.ts (16), knobs.test.ts (14), position.test.ts (12), and print.test.ts (3) passed on both at f95a11e, apart from the --knobs path test on Windows. The patch is the same at 78525ef, where both jobs pass.

Suggestions

  • src/keys/session.ts:72: type() writes entry.label, but nothing in src reads it. The knob line shows the entry on session.chosen, and complete() acts on this.knobs[this.chosen]. Drop label, or have both readers use it.
  • docs/keys.md:705: the panic row says that panic releases every note, stops a held turn, and sends All Notes Off. Panic now also stops every glide, as "Type a value" says. Add that to the row.

Plan conformance

  • Typing and completing. A type key opens an entry on the chosen knob, and the knob line shows it in the value's place with the units, as cutoff 800_ Hz. Enter clamps the number to the range and takes the controller value whose mapped value is nearest (§2.7 steps 1 to 3). 800 on cutoff lands on 62, which maps to 809.6 Hz, against 774.0 Hz for 61. Criterion 23 holds: 0.8 on attack lands on 96, which maps to 0.7824 s and prints 782 ms, against 0.8247 s for 97.
  • The glide. A glide moves 127 / glide controller values a second, counted from the press, so a late tick catches up. Each tick sends at most one control change per controller, and the last tick lands on the target. From 127 to 62 takes 13 ticks, as the session test asserts. A turn of the gliding knob, a panic, a keymap reload, and quitting each stop it (§2.7).
  • Period. The session checks Period before the keymap, so it types . only while an entry is open, and that press records nothing, so its release sends nothing. A bend that Period began stays in heldControls and ends on the release, even if an entry opened meanwhile (§3.2).
  • Quitting. isQuit no longer matches Esc. A raw \x03 and CSI 99;5u still quit, and so does a layout whose c position types another letter, through its base key. A sequence split across reads comes back as rest, and the next read is decoded with it prefixed, both while the daemon answers and in the play loop. Ctrl-D quit neither before this change nor after it. Esc resolves to the Escape position, which cancels an entry or puts Ctrl-C quits on the status line (§3.1).
  • Other keymaps. tracker and fourths bind no type, so no entry opens there and . plays its note: offset 14 in tracker, and a cell of the bottom row in fourths. The Logic number-row controls in docs/keys.md bind no type either.
  • Schema. type takes 0 to 9 or "-", and refuses ".", 10, and "1". glide is at least 0 and defaults to 0. Enter and Backspace are not bindable positions, and Escape's reserved message names the new behavior (§2.3, §2.9).
  • Plans. instrument-knobs and keyboard-instrument are both in-progress at priority now, and this change flips neither, so no open question gates it. The dated note at keyboard-instrument.md §2.4 is the one that §2.9 asks for.

Comment thread src/keys/session.ts Resolved
ninjudd and others added 4 commits October 11, 2026 17:03
…eld keys on Ctrl-C alone (instrument-knobs.md chunk 2)

In musical the number row types the chosen knob's value, in its knob
file's units, and Enter completes it: the knob glides to the controller
value nearest the number at the keymap's glide, one control change a
tick, so a take keeps the glide and any instrument answers it. Period
types the decimal point while a value is open and bends otherwise,
Backspace edits, and a knob key completes the value first. Esc cancels
a value, or with none open says that Ctrl-C quits, and Ctrl-C alone
quits.

Co-Authored-By: Claude <[email protected]>
… moves

The timer's comment said it runs only while a turn key is held, and its
function was named tickWhileTurning, but the session ticks while a
glide moves as well. A maintainer who trusted the comment and stopped
the timer on a turn key's release would freeze every glide partway. The
comment now names both, the function is tickWhileMoving, and the plan's
§10.1 records the timer chunk 2 left.
The knob line shows an entry on the chosen knob, and completing it acts on
the chosen knob too, so nothing read the label the entry carried.

@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.8 · model claude-opus-5-5 · effort xhigh · CLEAN · took 3m 33s

This is chunk 2 of the instrument-knobs plan. In musical, the number row types the chosen knob's value in its knob file's units. Enter completes the value, and the knob glides to the nearest of its 128 controller values at the keymap's new glide speed. Period types the decimal point only while a value is open, and Esc cancels a value instead of quitting, so Ctrl-C alone quits. Since the review of 78525ef, three commits answer that review, and the branch was rebased onto #209's 3204492. Chunk 3, criteria 20 and 21, is #212's, and the criteria that need a kitty terminal and sound stay owed in plan §10.3.

1 finding thread: 1 resolved, 0 open

Covered 20 of 20 changed files; 0 generated files skipped.

The head is trusted. The chunk 2 commit carries a Co-Authored-By: Claude <[email protected]> trailer, which names the GitHub login claude, and that login has only read access. Justin ruled on 2026-10-11 that this trailer on his own commits does not make a head untrusted, so this review ran the head's code. A live field keys session was running on the review machine, so nothing ran that boots sclang, creates a MIDI source, or opens an audio device. The seven focused test files need none of those.

Earlier findings

  • The timer's comment and name are fixed. 88d4ee2 rewords the comment in src/commands/keys.ts to say that the 40 ms timer runs while a turn key is held or a glide moves. It renames tickWhileTurning to tickWhileMoving at all four sites, and nothing in the tree still names the old function. Plan §10.1 records the timer. The thread is resolved.
  • Both suggestions are taken. 2f0a24c drops label from the entry, and the one test that read it now expects { text: '800' }. cd79e60 adds every glide to what the panic row in docs/keys.md says a panic stops.

What moved under this pull request

git range-diff shows the rebase left the chunk 2 commit's patch unchanged, apart from one context line in src/keys/print.test.ts, where #209 now describes a knob key as moving the choice. #209's new commits change code beside this pull request's without overlapping it:

  • formatKnobValue prints a lin knob with a fractional step to the step's decimal places, which only widens such a knob's value and so the entry's padding.
  • The knob line cuts each knob to the room the window's markers leave. An entry passes through the same cut, so it loses characters only when its knob grows wider than the terminal.
  • juno.knobs.yaml changes only its comment, so 800 on cutoff still lands on 810 Hz and 0.8 on attack on 782 ms.

Checked

  • Gate. pnpm install --frozen-lockfile and pnpm typecheck pass at cd79e60. Vitest passes all 127 tests in the seven changed test files: session.test.ts (43), commands/keys.test.ts (20), schema/keymap.test.ts (18), terminal.test.ts (16), knobs.test.ts (15), position.test.ts (12), and print.test.ts (3). project check passes.
  • CI. linux and windows both pass at cd79e60.
  • Typing and the glide. Enter clamps the number to the knob's range and takes the nearest controller value. A glide moves by the time since it started, at most one control change per controller a tick, and lands on its target: 127 to 62 at glide: 1 takes 13 ticks. A turn of the gliding knob, a panic, a keymap reload, and quitting stop it.
  • Period. It types . only while an entry is open, and that press records nothing, so its release sends nothing. A bend that Period began ends on its release even if an entry opened meanwhile.
  • Quitting. Only Ctrl-C quits: a raw \x03, CSI 99;5u, or the US c position on a layout without a c. A sequence split across reads is decoded with the next read. Esc cancels an entry or puts Ctrl-C quits on the status line.
  • Other keymaps. tracker and fourths bind no type, so no entry opens there, and . keeps playing its note.
  • Plans. instrument-knobs and keyboard-instrument stay in-progress at priority now, so no open question gates this change.

The head looks clean.

@ninjudd
ninjudd marked this pull request as ready for review October 11, 2026 21:23
@ninjudd
ninjudd merged commit e791a11 into main Oct 11, 2026
11 of 13 checks passed
@ninjudd
ninjudd deleted the knobs/type branch October 11, 2026 21:33
ninjudd added a commit that referenced this pull request Oct 11, 2026
…ent, and the daemon chases it to the take's first sample (instrument-knobs.md chunk 3) (#212)

A MIDI take records only the messages that arrive once it has started.
So a knob you turned before pressing record, such as `juno`'s cutoff
dialed down for a darker pad, played live but rendered at its default in
the take until you happened to turn it again. The same gap hit the
modulation wheel, and keyboard-instrument.md §14.5 left it open. This
third chunk of the instrument-knobs plan (#202) closes it in the daemon,
with MIDI alone, so it works for any source.

There are three parts:

- **`field keys` publishes what it has sent.** Run inside a project, it
keeps every controller from 0 to 119 it has sent, by channel, in
`.field/keys.json`, written to a temporary file and renamed over the
last on each control change, and removed when it quits. A `field keys`
removes the file only if it wrote it, so two in one project do not
delete each other's. One that cannot write the file keeps playing and
names the error on the status line, and a take then starts without its
knobs.
- **`field record` passes them in `arm`.** When it arms a MIDI take, in
the one-track form or with `tracks`, and the `field keys` that wrote the
file is still running, it adds `controllers` to `arm`. It does so only
for a daemon that lists the new `midi-chase` feature, so an older daemon
never sees the field.
- **The daemon chases controllers.** From the arm, it keeps the latest
value of each controller from 0 to 119 on each channel: the ones `arm`
passed, then every control change that arrives, a count-in included,
whether before the take, during it, or past its `until`. Before this
change it dropped those that arrived before the start. At the take's
first sample it writes one line per channel and controller at `at: 0`,
ahead of every other line, in the order the values last arrived, in each
MIDI take of the pass. Controllers 120 to 127 are channel mode messages
and are never chased. A hardware knob moved after the arm counts too. A
change the take records enters the table only after those lines, so a
second take on one arm, which arming.md chunk 3's lasting arm will make,
starts each controller where the first take left it.

On the audio thread, the chase is a fixed table of 16 channels by 120
controllers, updated in constant time per message wherever the callback
used to discard arrivals before the start. `arm` hands its seeds to the
callback under a spin lock that the callback only ever tries, so it
never blocks, and each arm starts the table over. The lines go in just
before the take's first stamped message. So an arrival in the start
block that falls before the start sample is chased before the lines are
written, and the lines still lead the file. `arm` refuses `controllers`
out of range, as it refuses a bad input channel. A block whose pull ran
before `record`'s request, which #204 lets wait for the next block to
start the take, chases what it drains too, because that arrived before
the start.

#209 and #210, chunks 1 and 2, are on `main`, and this branch is rebased
onto it, #213's host monitoring included. `armSet` takes the chase's
seeds and then #213's connection `owner`, and the `tracks` form of `arm`
passes both. With this, every chunk of the plan is built, and what
remains is the criteria to check by hand. §11 of the plan records what
implementation settled.

## Testing

I ran these on macOS, from the root of a checkout of this branch, after
`pnpm install`, `pnpm build`, and `pnpm build:native`. `pnpm
build:native` matters here, since this change is in the daemon. Against
a daemon built before it, the `midi-chase` tests fail on
`client.supports('midi-chase')`.

1. `pnpm typecheck` prints nothing and exits 0.
2. `pnpm vitest run` reports 91 test files, 1216 tests passed and 1
skipped.
3. `pnpm vitest run src/commands/record-midi-daemon.test.ts
src/commands/record-plan.test.ts` passes 16 tests and skips 1, which
runs only where there is no MIDI service. The daemon tests publish a
CoreMIDI source of their own, `Field Keys Capture <pid> …`, for a few
seconds, and arm a daemon of their own in null-output mode; they touch
no running daemon. The chase test seeds `cc 110 = 10` and `cc 111 = 20`
on channel 16 at the arm. Before the start, it sends `cc 112 = 30` on
channel 15, `cc 110 = 40` on 16, and CC 120; after the start, `cc 111 =
50`. The take's lines at `at: 0` must be `cc 111 = 20`, `cc 112 = 30`,
`cc 110 = 40`, in that order, with no CC 120, and `cc 111 = 50` must
land later at its own time. Lines in another order mean the chase no
longer orders by last arrival. A `cc 110 = 10` line means a seed was not
replaced. The `field record` test publishes `.field/keys.json` as its
own process and checks that the landed notes file has `{ at: 0, cc: 113,
value: 23, channel: 16 }`. The latch test sets
`FIELD_AUDIOD_LATCH_STALL_MS=8` and sends a controller just before each
of ten `record`s on one arm. "the controller sent before take N:
expected [] to have a length of 1" means a block whose pull ran before
`record`'s request dropped what it drained instead of chasing it. The
carry test records twice on one arm, with `cc 114 = 20` before the first
take and `cc 114 = 50` during it, and the second take's line at `at: 0`
must be `cc 114 = 50`. `cc 114 = 20` there means a change the take
recorded never reached the chase.

What I could not run is criteria 20 and 21 by hand, which need a kitty
terminal and ears. From `examples/bloom`, give `creek` a track `keys`
with `instrument: juno`. In one terminal, run `node ../../dist/cli.js
keys juno` and turn `cutoff` down. In another, run `node
../../dist/cli.js record creek/track:keys --at 17`, play without
touching a knob, stop, build, and play. The take should render dark from
its first note, and its notes file's first `controls` row should be `{
at: 0, cc: 74, value: … }`. Both terminals need this branch's `dist` and
daemon: a daemon left running from another build answers without
`midi-chase`, so run `field transport quit` first. With `--count-in 1`,
turning `res` during the count-in should start the take with that `res`.

<!-- projector-summary v=1 sha=68d929f49bdbec524a494779a2cfc85fb8ff5fb9
-->
📽️ **Projector summary** of 68d929f: https://field.amnes.ac/reviews/212
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