Skip to content

Hear a microphone through its track while it records: field record --monitoring host (live-supercollider.md chunk 4) - #213

Merged
ninjudd merged 4 commits into
mainfrom
live/monitor
Oct 11, 2026
Merged

ninjudd merged 4 commits into
mainfrom
live/monitor

Conversation

@ninjudd

@ninjudd ninjudd commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Field could record a microphone but never let you hear it through the song. field record --monitoring <mode> only wrote the mode on the take's row, because recording.md left monitoring to the interface's mixer: the armed input reached only the capture queue and the meter. Live-supercollider chunks 1 to 3 built the path a live input takes through a track's chains, and chunk 4 points the microphone down it. With --monitoring host, each armed audio track's input plays through that track's inserts, the buses above it, and main, from arming through the count-in and the take, while the take stays the dry input. The default stays apollo-direct, which plays nothing of the input.

The armed input becomes a second kind of live input. arm takes a monitor name on each audio entry, and the daemon opens a capture input under that name. Each callback presents its input block before the session renders, and the capture input reads its channel from that block. It reads from a cursor that starts again each block, because the session reads a block in steps where a loop wraps. field record then loads the song again with an input window on the track, the way field keys does for a ring, and loads it once more without it after it disarms. Disarming closes the capture inputs, and so does a dropped connection. The session format, its version, and the live engine are unchanged. liveInputsFor and reloadWithInputs move from src/keys/routing.ts to src/audiod/live-inputs.ts. Every command that reloads a song (field play, its watch, field ui, field record, and field keys) now keeps a monitored input as well as a routed voice.

field record refuses host monitoring before it arms in these cases:

  • a file bed, which can carry no input window;
  • a daemon playing another song;
  • a device that the daemon converts the song for, whose session-rate steps are not the callback's frames. field keys refuses the same case;
  • a track that a solo, a muted placement, or the arrangement keeps from main, found by compiling the song as the reload will.

After arming, it also refuses a device that a separate input opened at another rate. Whatever throws after an arm that succeeded, field record releases it. The reload after the take happens only while the daemon still plays the song and no take records, and field keys' reload on quit does the same, so a song another terminal loaded meanwhile plays on.

Separate input and output devices are allowed, because JUCE combines them into one callback, at the cost of the combiner's added latency. The bypass-and-report latency policy in audio-engine.md is not built. What you hear is late by both buffers and by the limiters and hosted plugins on the path, until criterion 6 measures it by ear. Plan §12 records these calls for review, with the alternatives that lost. recording.md §8 and §13.6 carry dated amendments.

Testing

From the repository root of this branch, after pnpm install and pnpm build:native (the daemon changed):

pnpm typecheck
native/audiod/build/field-audiod_artefacts/Release/field-audiod --capture-selftest
FIELD_AUDIOD=$PWD/native/audiod/build/field-audiod_artefacts/Release/field-audiod pnpm exec vitest run src/audiod/live-monitor.test.ts src/commands/record-daemon.test.ts src/keys/routing.test.ts
FIELD_AUDIOD=$PWD/native/audiod/build/field-audiod_artefacts/Release/field-audiod pnpm test
project check

The typecheck passes, and --capture-selftest prints {"ok":true}. It reads a capture input whole, in a loop wrap's steps, past its block, with nothing presented, and closed. The three focused files pass. The full suite passes 1132 with 1 skipped: the no-MIDI-source case, which runs only without a MIDI service. project check passes with its standing site-workflow warning.

live-monitor.test.ts arms the null clock's sawtooth with monitor and loads a session that names it. It finds the input read at full scale while stopped and while playing. It checks that disarming and a dropped connection each close the input, while the arm stays. It checks the refusals: a monitored MIDI track, one name used twice, and a name a ring already has, in either order. record-daemon.test.ts runs field record --monitoring host and watches status from a second connection:

  • while the take records, the input is read at full scale;
  • the take lands dry and gapless, with monitoring: host on its row;
  • the song is loaded again without the input;
  • a file bed is refused before anything arms.

The change is wrong if any of these appear:

  • a capture input that reads nothing while armed under a loaded song;
  • a take whose audio carries the track's effects;
  • status.inputs still listing capture: after field record returns.

The tests use the null device and leave nothing behind outside their temporary directories.

Criterion 6 can't be exercised in CI because it needs a microphone and headphones. In a project with a song whose track has an insert and reaches main, run field record <song>/track:<track> --monitoring host --at 2 --count-in 1. You should hear yourself through the insert during the count-in and the take, and the landed take should be dry.

📽️ Projector summary of eeeaa4e: https://field.amnes.ac/reviews/213

…monitoring host (live-supercollider.md chunk 4)

field record has recorded a --monitoring mode on each take's row since recording.md, but monitoring itself was the interface's job: the armed input reached only the capture queue and the meter. With --monitoring host, each armed audio track's input now plays through that track's inserts, the buses above it, and main, from arming through the count-in and the take, while the take stays the dry input.

The armed input is a second kind of live input. arm takes a monitor name on each audio entry, and the daemon opens a capture input under it that reads that channel from the block the callback is in, presented before the session renders. field record then loads the song again with an input window on the track, as field keys does for a ring, and loads it once more without it after disarming. A dropped connection closes its capture inputs. The session format and the live engine are unchanged. field record refuses host monitoring over a file bed, another song, or a device the daemon converts the song for. liveInputsFor and reloadWithInputs move to src/audiod/live-inputs.ts, so every command that reloads a song keeps both kinds of input.

@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 · CHANGES REQUESTED · took 30m 22s

This change lets field record --monitoring host play each armed audio track's input through that track's inserts, the buses above it, and main, from arming until the take ends, while the take itself stays the dry input. The daemon gains a second kind of live input, a capture input that reads its channel straight from the callback's input block, and every command that reloads a song keeps both kinds through liveInputsFor. It knowingly leaves the latency policy unbuilt, refuses converted delivery, and leaves criterion 6, a microphone heard through headphones, to a check on hardware.

3 finding threads: 0 resolved, 3 open

Covered 23 of 23 changed files; none is generated.

Disclosures:

  • Null device only. Another session was using this machine's audio and MIDI devices, so every test ran against the daemon's null device, and nothing opened a real input, armed MIDI, or booted scsynth. I ran the five focused files, not the full suite.
  • Criterion 6 and the device-rate finding are unexercised. Both need real devices. The rate finding rests on reading JUCE 8.0.4's AudioIODeviceCombiner::getAvailableSampleRates and AudioDeviceManager::chooseBestSampleRate beside Player::maybeMatchDeviceRate.

Suggestions

  • src/commands/record.ts:357: add "use headphones" to the monitor line. docs/cli.md warns that a microphone the speakers reach feeds back, but nothing says so at run time.
  • src/commands/record.ts:243: the bed load repeats reloadWithInputs' fresh-load branch, and its lazy import('../graph/live.js') defers nothing now that line 2 imports live-inputs.js. Call reloadWithInputs there.
  • src/commands/record.ts:230: monitored needs no declaration outside the try. Make it a const where line 278 computes it.
  • src/keys/routing.ts:136: at the base, field keys' reload on quit has the shape of the line 471 finding. It loads its song even when the daemon now plays another.

What I checked

  • Readiness gate. live-supercollider stays in-progress. This change adds §12 with its decisions recorded and opens no question. §7's three questions predate it: two were taken as recommended, and one is deferred to arming.md chunk 3. recording is completed, which makes no readiness claim.
  • Feedback. The default stays apollo-direct, host is opt-in, and docs/cli.md says to use headphones.
  • The take stays dry. pullAudio only reads the callback's input, and the capture tap reads it after the render. The new record test lands the take gapless against the null sawtooth.
  • Callback safety. CaptureBlock::present, clear, and CaptureInput::read allocate nothing and take no lock. They run only on the callback's thread inside liveLock's try-lock, and every locate turns input reads off. In steady state a block reads exactly its own frames, so the per-block cursor neither pads nor drops. One session renders per block, and LiveSession refuses an input named twice, so no capture input is read twice in a block.
  • Channel mapping. channelIndex matches the callback's active-only input array for several armed inputs and for the null clock, and read bounds-checks the channel.
  • Cleanup. Disarm, a re-arm, a dropped connection, and quit each close the capture inputs, and closeCaptures runs only after armSet can no longer fail. Under converted delivery a capture input reads silence.
  • Latency. What you hear is late by the input and output buffers plus the path's limiters and hosted plugins, as §12.3 records. Nothing re-times the take.
  • What ran. pnpm install --frozen-lockfile, pnpm typecheck, and a Release build of field-audiod and FieldOut all passed. field-audiod --capture-selftest printed {"ok":true}. live-monitor.test.ts, record-daemon.test.ts, routing.test.ts, live-input.test.ts, and live-session.test.ts passed 39 of 39. project check passed with its two standing warnings. CI's linux, windows, and CodeQL jobs passed on this head.

Comment thread src/commands/record.ts Resolved
Comment thread src/commands/record.ts Resolved
Comment thread src/commands/record.ts Resolved
…m whatever throws after it, and leave another terminal's song alone

A track the loaded solo, a muted placement, or the arrangement kept from main failed only at the reload after arming, which left the input armed; field record now compiles the song as that reload will, with the capture inputs, before it arms, and refuses there. A separate input device can open the pair at a rate the song is not, which converted delivery then silences; field record refuses that after the arm. Whatever throws after the arm, the function's own finally releases it, which also covers --at, --until, and click errors that leaked an arm before. The reload after a take, and field keys' reload on quit, now happen only while the daemon still plays the song, so a song another terminal loaded meanwhile plays on. compileWithInputs and reloadIfPlaying join src/audiod/live-inputs.ts; the bed load uses reloadWithInputs; the monitor line says to use headphones.

@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 · CHANGES REQUESTED · took 5m 59s

This change lets field record --monitoring host play each armed audio track's input through that track's inserts, the buses above it, and main, from arming until the take ends, while the take itself stays the dry input. The daemon gains a second kind of live input, a capture input that reads its channel straight from the callback's input block, and every command that reloads a song keeps both kinds through liveInputsFor. This head answers the first review. It refuses before arming a track the song cannot hear, and refuses after arming a device rate the song is not. It releases the arm whatever throws after it, and reloads after a take only while the daemon still plays the song. It still leaves the latency policy unbuilt, refuses converted delivery, and leaves criterion 6 to a check on hardware.

6 finding threads: 3 resolved, 3 open

Covered 23 of 23 changed files; none is generated. The three findings from f4f8f47 are fixed at this head:

  • The track the song cannot hear. compileWithInputs now compiles the song with the capture inputs before arming. My two null-daemon reproductions, a session soloed on another track and a track not placed in main, now refuse before arming, with record.state left idle.
  • The device rate. After arming, field record refuses when armed.sample_rate differs from the song's rate. armSet returns the device's rate, and status.sample_rate under a live session is the song's. The function's finally releases the arm, and its reload lets maybeMatchDeviceRate put the output back at the song's rate.
  • The song another terminal loads. reloadIfPlaying reloads only while the daemon still plays the take's song. In my reproduction, tall-grass, loaded mid-take, now plays on.

Disclosures:

  • Null device only. Another session was using this machine's audio and MIDI devices, so every test ran against the daemon's null device. Nothing opened a real input, armed MIDI, or booted scsynth. No native file changed since f4f8f47, so the tests ran against that head's daemon build. I ran the five focused files, not the full suite.
  • CI failed on two tests that do not exercise this change. On linux, src/keys/voice-host.test.ts "asks the host to reload…" drives a stand-in sclang through VoiceHost, and saw one status event in the two seconds it waits for two. On windows, src/commands/push.test.ts "pushes without a remote…" took 9.2 s against its 5 s timeout. Neither runs the record or reload code this head changed, and both jobs passed on f4f8f47, so I read both as timing flakes.
  • The rate refusal is verified by reading, because no null-device test can reach it.

What I checked

  • Readiness gate. live-supercollider stays in-progress, and this head opens no question. recording is completed.
  • The new reload rules. field keys' close and its failed-route path now use reloadIfPlaying, and the new routing test leaves tall-grass playing.
  • Errors after the arm. The outer finally now releases the arm for every error after it, including --at, --until, and click errors, which left the input armed before this pull request.
  • What ran. pnpm install --frozen-lockfile and pnpm typecheck passed. field-audiod --capture-selftest printed {"ok":true}. live-monitor.test.ts, record-daemon.test.ts, routing.test.ts, live-input.test.ts, and live-session.test.ts passed 42 of 42. project check passed with its standing site-workflow warning.

Comment thread src/commands/record.ts Resolved
Comment thread docs/audio-engine.md Resolved
… none records

armedHere turned true before the arm call returned, so a monitored field record refused under another terminal's take still ran the reload in its finally, swapping that take's bed for a session without its region, and the other terminal's loop stopped wrapping. armedHere is now set once the arm returns, and reloadIfPlaying skips while any take records, as field keys' close already did, which now relies on it. The plan's log says the rate refusal has no test, because the null device runs only at 48 kHz, and leaves it to criterion 6's hardware session; audio-engine.md's paragraph rewraps.

@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 5m 59s

This change lets field record --monitoring host play each armed audio track's input through that track's inserts, the buses above it, and main, from arming until the take ends, while the take itself stays the dry input. The daemon gains a second kind of live input, a capture input that reads its channel straight from the callback's input block, and every command that reloads a song keeps both kinds through liveInputsFor. This head answers the second review. It releases only an arm that succeeded, and it reloads after a take only while the daemon still plays the song and no take records. The plan now says which gap has no test. It still leaves the latency policy unbuilt, refuses converted delivery, and leaves criterion 6 to a check on hardware.

6 finding threads: 6 resolved, 0 open

Covered 23 of 23 changed files; none is generated. Every finding from the two earlier reviews is fixed at this head:

  • A refused arm under another terminal's take. armedHere now turns true only after the arm call returns, and reloadIfPlaying skips while any take records, which recordState reports whenever a capture exists, a pending count-in included. In my null-daemon reproduction, a monitored field record refused under another client's loop take over samples 0 to 24000 now leaves that take's loop_from and loop_to in place. The take keeps wrapping and lands passes 2 through 6 with none missed.
  • The plan's test claim. The chunk 4 log now names what verifies each gap. It says that no test reaches the rate refusal, and why.
  • The audio-engine.md wrapping. The paragraph is rewrapped within 72 columns.
  • The three findings from f4f8f47. They still hold. A solo on another track and a track not placed in main refuse before arming, with record.state left idle. A song another terminal loads mid-take plays on. The after-arm rate refusal is unchanged.

Disclosures:

  • Null device only. Another session was using this machine's audio and MIDI devices, so every test ran against the daemon's null device. Nothing opened a real input, armed MIDI, or booted scsynth. No native file changed since f4f8f47, so the tests ran against that head's daemon build. I ran the five focused files, not the full suite.
  • CI's windows job failed on a test that does not exercise this change. src/commands/pull.test.ts "pulls, then warms the cache for HEAD…" hit its 10 s hook timeout at 11.6 s. The same file hit the same hook timeout today on the projector-agents-v4 branch. push.test.ts timed out on main at d94b734, and voice-host.test.ts failed on knobs/type. I read this as the recurring timing flake in those tests. linux, CodeQL, and the analyzers passed.
  • The rate refusal is verified by reading, because no null-device test can reach it.

What I checked

  • Readiness gate. live-supercollider stays in-progress, and none of the three heads opens a question. Its §7 questions predate this pull request. recording is completed, which makes no readiness claim.
  • Feedback. The default stays apollo-direct, host is opt-in, and both docs/cli.md and the monitor line say to use headphones.
  • The take stays dry. pullAudio only reads the callback's input, and the capture tap reads it after the render. The record test lands the take gapless against the null sawtooth.
  • Callback safety. CaptureBlock::present, clear, and CaptureInput::read allocate nothing and take no lock. They run only on the callback's thread inside liveLock's try-lock, and every locate turns input reads off. In steady state a block reads exactly its own frames, so the per-block cursor neither pads nor drops. One session renders per block, and LiveSession refuses an input named twice.
  • Cleanup. Disarm, a re-arm, a dropped connection, and quit each close the capture inputs. field record releases its own arm for every error after it, and only its own.
  • Latency. What you hear is late by the input and output buffers plus the path's limiters and hosted plugins, as §12.3 records. Nothing re-times the take.
  • What ran. pnpm install --frozen-lockfile and pnpm typecheck passed. field-audiod --capture-selftest printed {"ok":true}. live-monitor.test.ts, record-daemon.test.ts, routing.test.ts, live-input.test.ts, and live-session.test.ts passed 43 of 43. project check passed with its standing site-workflow warning.

@ninjudd
ninjudd marked this pull request as ready for review October 11, 2026 21:08
# Conflicts:
#	native/audiod/src/player.cpp

@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 6m 55s

This change lets field record --monitoring host play each armed audio track's input through that track's inserts, the buses above it, and main, from arming until the take ends, while the take itself stays the dry input. The daemon gains a second kind of live input, a capture input that reads its channel straight from the callback's input block, and every command that reloads a song keeps both kinds through liveInputsFor. This head merges main, which brings #204's loop-take handoff, #215's Projector refresh, and #208's release CI. Apart from resolving one conflict, the pull request's own change is the one reviewed clean at 3b36c2b. It still leaves the latency policy unbuilt, refuses converted delivery, and leaves criterion 6 to a check on hardware.

6 finding threads: 6 resolved, 0 open

Covered 23 of 23 changed files; none is generated. The base's own changes are #204, #215, and #208, and I read them only where they meet this change.

  • The conflict. Player's constructor met #204's three stall seams. The resolution keeps #204's serviceStallMs, openStallMs, and latchStallMs and appends captureBlock, which matches the declaration order in player.h. The build reports no reorder warning. Against the new base, the pull request's player.cpp change is otherwise the same as at 3b36c2b.
  • #204 beside the capture path. pullAudio now sets blockSawRequest under liveLock before the render, and the capture block's present and clear still bracket the render inside the same lock. #204's seek, which jumps to at once a take's transactions are open, holds liveLock and goes through LiveSession::locate. That turns input reads off, so it never reads a capture input off the audio thread. The latch stall seam in processBlock runs after the pull, once the block is already cleared.
  • #204's region carry and this pull request's reloads. loadSession still hands the new session the open capture inputs. A swap #204 refuses for a region that does not fit retires the session on the message thread, which releases those inputs there. reloadIfPlaying still skips while a take records. #204 now carries a loop take's region across a swap, so that skip no longer protects the region alone, and it still keeps the other take's bed.
  • Earlier findings. All six finding threads stay fixed at this head. My four null-daemon reproductions still hold. A solo on another track and a track not placed in main refuse before arming, with record.state left idle. A song another terminal loads mid-take plays on. A monitored field record refused under another client's loop take leaves that take's region in place, and the take wraps and lands passes with none missed.

Disclosures:

  • Null device only. Another session was using this machine's audio and MIDI devices, so every test ran against the daemon's null device. Nothing opened a real input, armed MIDI, or booted scsynth. I ran the six files below, not the full suite.
  • The rate refusal is verified by reading, because no null-device test can reach it.

What I checked

  • Readiness gate. live-supercollider stays in-progress, and this head opens no question. recording is completed. The merge brings #204's recording.md additions beside this pull request's amendments, and they do not conflict.
  • Feedback, the dry take, callback safety, cleanup, and latency are unchanged since the clean review of 3b36c2b. That review covers them.
  • What ran. pnpm install --frozen-lockfile and pnpm typecheck passed. A Release build of field-audiod at this head built with no new warning. field-audiod --capture-selftest printed {"ok":true}. live-monitor.test.ts, record-daemon.test.ts, routing.test.ts, live-input.test.ts, live-session.test.ts, and #204's punch-daemon.test.ts passed 55 of 55. project check passed with no warning. CI's linux, windows, and CodeQL jobs passed on this head.

@ninjudd
ninjudd merged commit 42debe8 into main Oct 11, 2026
7 checks passed
@ninjudd
ninjudd deleted the live/monitor branch October 11, 2026 21:28
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
ninjudd added a commit that referenced this pull request Oct 12, 2026
…hile it is held (#225)

`field keys` told you what you were playing only as note names at the
end of the status line, so finding a key, or seeing which keys a chord
used, meant reading text. This change draws the keyboard in the
terminal: the keys that play notes, as keycaps with their letters, laid
out so the black keys sit between the white keys as they do on a piano.
Each key lights in reverse video while you hold it.

```
  ┌───┬───┐   ┌───┬───┬───┐   ┌───┬───┐   ┌───┐
  │ W │ E │   │ T │ Y │ U │   │ O │ P │   │ ] │
┌─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┘
│ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
mod   0
Field Keys · musical · transpose 0 · velocity 100 · bend +0 · –
```

The drawing sits between the instrument's line and the knob line, and
redraws in place from the first line that changes, as those lines
already do. The row above the home row sits half a key to the left, so
`W` falls between `A` and `S`. A key that plays nothing, such as `Q`,
`R`, `I`, or `[` in `musical`, leaves a gap, which is what makes it read
as a piano. `src/keys/keyboard.ts` lays each key out as a rectangle on a
character grid and picks each box-drawing character from the lines that
meet in its cell. That keeps the junctions right where the offset row
meets the home row.

As Justin asked, this does the work for `musical` only for now. It draws
a keymap whose notes are all on the home row and the row above it, and
draws nothing for `tracker` and `fourths`, whose notes span four rows
and start elsewhere; they can come later. It also draws nothing on a
terminal too narrow for it, rather than draw it broken. `musical`'s
drawing is 47 columns wide, and `field keys` draws in one column less
than the terminal has, so it needs a terminal of 48 columns.

`musical` gains F#5 on `]`. It is the next black key after `'` (F5), so
it completes the pattern the drawing shows, and Justin listed it among
the keys to draw. Every other key plays what it did.

## Testing

I ran these on macOS from the root of a checkout of this branch, after
`pnpm install` and `pnpm build`.

1. `pnpm typecheck` prints nothing and exits 0; `project check` reports
the plans valid; `git diff --check` is clean.
2. `pnpm vitest run src/keys src/schema src/commands/keys.test.ts`
passes 225 tests. `src/keys/keyboard.test.ts` pins `musical`'s drawing
line by line, the reverse video on a held key on each row (and on no
other line), no drawing for `tracker`, `fourths`, or a width of 46
columns, which is what a 47-column terminal gives the drawing, and a
keymap of your own with three keys. A changed line in the first test
means the layout or a junction moved.
3. The full suite, `pnpm vitest run`, against a `field-audiod` built
from this branch's `main`: 92 test files, 1308 tests passed and 1
skipped. A daemon built before #212 and #213 fails ten daemon tests for
their features, the second-take chase and host monitoring, with nothing
to do with this change.
4. `node dist/cli.js keys --print` shows `F#5` on `]` in `musical`'s
diagram.

I also drove `field keys` in a pseudo-terminal with the kitty protocol's
key events, against a stand-in for `field-audiod --keys` that logs what
it is sent and publishes no MIDI source. The first screen drew the
keyboard above `mod 0` and the status line. Holding `A` put `A`'s face
in reverse video and the status line read `C4`; adding `W` lit both and
read `C4 C#4`; releasing both cleared them, and the stand-in logged two
note-ons and two note-offs.

To see it yourself, run this in Ghostty or iTerm2 from `examples/bloom`,
with no other `field keys` running: `node ../../dist/cli.js keys juno`.
Hold a few keys: each lights while held and goes dark on release, and
`]` plays F#5. `--keymap tracker` shows no drawing, as expected for now.

<!-- projector-summary v=1 sha=6fb0066d533a2c262981b33f3fa72588c15d96aa
-->
📽️ **Projector summary** of 6fb0066: https://field.amnes.ac/reviews/225

This branch was previously deployed

1 inactive deployment
github-pages — eeeaa4e1 Deployed Oct 11, 2026 by ninjudd via publish #150
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