Repository navigation
Record several armed tracks in one pass: audio, MIDI, or both (arming.md chunk 2) - #191
Conversation
….md chunk 2) field record takes any number of tracks. planArm resolves each to its record entry and kind, gives each audio track its --input in order, 1, 2, and on by default, and refuses a track named twice, tracks in two songs, audio flags on MIDI-only sets, and --loop over more than one track. One track arms as before; several arm through the daemon's arm with tracks, and every take lands on its own track. In field-audiod, arm and armMidi are one-entry forms of armSet. The first armed track is the primary, on which every existing capture rule runs unchanged; the rest are companions in fixed slots the callback reads through atomics. They start on the primary's latch, an audio companion pushes the same span of its own input, and they end with the pass. An audio track is the primary whenever one is armed, so --until still cuts audio exactly; the MIDI clock's stamping is one step that a MIDI primary's companions mirror and an audio primary's MIDI companions run, ending a block after the audio. stop returns every manifest as takes beside take, status lists armed when more than one track is, and the null input presents each armed channel. Loop takes stay one track. docs/audio-engine.md, docs/cli.md (which also gains its missing field keys row), and docs/keys.md describe it; plan §10 records the chunk and a pre-existing 3-sample punch-out shortfall against a file bed.
ninjudd
left a comment
There was a problem hiding this comment.
📽️ Projector review · 0.7.4 · model claude-opus-5-5 · effort xhigh · CHANGES REQUESTED · took 25m 00s
This change lets field record arm and record several tracks in one pass, any mix of audio and MIDI, as chunk 2 of the arming plan. The CLI resolves every target before anything opens and gives the audio tracks their inputs in the order named. The daemon keeps every existing capture rule on one primary track and adds up to 15 companions in fixed slots that the audio callback reads only through atomics; they start on the primary's latch and end with its pass, and stop, status, recordings, and recover learn about every take. It knowingly leaves loop takes to one track, MIDI routing to unison, the lasting arm to chunk 3, and plan criteria 6 to 8 to a hand test on a real interface.
2 finding threads: 0 resolved, 2 open
Covered 17 of 17 changed files; none are generated.
- No real device. I opened no audio or MIDI device. The daemon tests run in null-output mode, with
field-audiod --keyspublishing a virtual MIDI source. The arm finding rests on reading, because null mode never opens a device. - Windows CI. The Windows job fails 19 tests against the base branch's 12. Five are this change's new test file, which a thread covers. The other two are a 5-second timeout in
live-session.test.tsand theinventory cachecase inplugin-hosting.test.ts, a known flake; neither runs code this change touches.
The arming plan is in-progress. This change adds §10 and no open question. Of §7's questions, the first belongs to chunk 3 and the other two are explicitly deferred. §10 records criteria 6 to 8 as owed by hand and the file-bed punch-out as outside this chunk, so the readiness gate holds.
Suggestions
src/commands/record.ts:481: after the recordings fallback, name each transaction instarted.takesthat never landed, withfield record --recover <id>. A take whose finalize throws is left out ofstop'stakesand sends no event, so beside a take that lands it goes unreported andfield recordexits 0, where one track with the same failure throws "its manifest never arrived".src/commands/transport.ts:129:field transport statusprints only the primary's track and input. Readstatus.record.armedso a second terminal sees every armed track.docs/projects/arming/readme.md:94: the shapes table gives eacharmedentry "input or sources", but the daemon puts nosourceson a MIDI entry; they stay onstatus.recorditself. Make the two agree.docs/projects/arming/readme.md:256: the file-bed punch-out that ends 3 samples short is recorded only as "not this chunk's". Give it a home that tracks it, such as an issue or the recording plan.
What holds
- The callback.
recordAudioBlock,recordMidiCompanions, andstampMidiBlockallocate nothing, take no lock, and do no I/O; the added work is a bounded loop over at most 15 slots. - Detach and finalize.
stopRecordingkeeps the wait for two epochs before the MIDI detach and after it, and covers the companions in both. After a punch-out,serviceCapturefinalizes a companion only after the callback has cleared its pointer and setcaptureDone, in either order of the audio cut and the MIDI end. - The MIDI clock. Companions of an audio primary stamp against
midiUntilFrames, which convertsuntilto the device's samples as #182 settled. OnemidiArrivalsLostexchange per block feeds every take'sdropped, and a block with no MIDI take running still drains the queue. - Crash safety. Each companion is its own transaction with its own journal, so
recordingslists it as active andrecoverrefuses it while it records. - Protocol. Every reader of
stop,record,arm, andstatus.recordinsrc/reads the new fields as optional, so a one-track daemon and a one-track CLI behave as before.
I ran pnpm install --frozen-lockfile, pnpm typecheck, and project check, which all pass; record-plan.test.ts and cliParsers.test.ts, 16 of 16; a Release field-audiod built from this head, with no warnings from native/audiod/src; and against it record-tracks-daemon, record-daemon, record-midi-daemon, punch-daemon, click-daemon, and play-daemon, 42 passed and 1 skipped, the no-source case this machine's MIDI service rules out.
armSet opened the duplex input before looking for MIDI sources, so a set refused for its MIDI left the microphone open with nothing armed, or a previous audio arm's channels changed under it. MIDI sources now open first, unstarted, so a MIDI refusal returns before the device changes and an audio failure drops only those inputs; the companions stop being read only once a failed close can no longer leave the arm before them. field transport status lists every armed track, a MIDI one by the sources it hears, and status.record names those sources for an audio primary's MIDI companions too. When one take of several never arrives, field record exits naming the track and its --recover command. The new daemon test skips its MIDI cases on Windows and cleans up with removeTempProject, and the plan points the file-bed punch-out at #194.
ninjudd
left a comment
There was a problem hiding this comment.
📽️ Projector review · 0.7.4 · model claude-opus-5-5 · effort xhigh · CHANGES REQUESTED · took 28m 30s
This change lets field record arm and record several tracks in one pass, any mix of audio and MIDI, as chunk 2 of the arming plan. The CLI resolves every target before anything opens. The daemon keeps every capture rule on one primary track and adds up to 15 companions that the audio callback reads only through atomics. This head answers the first review: armSet opens its MIDI sources before the audio device, the new daemon test skips its MIDI cases on Windows and cleans up with removeTempProject, and the four suggestions are taken. It knowingly leaves loop takes to one track, MIDI routing to unison, the lasting arm to chunk 3, and plan criteria 6 to 8 to a hand test on a real interface.
3 finding threads: 2 resolved, 1 open
Covered 18 of 18 changed files; none are generated. I read the whole diff on the first head and, on this head, the new commit in full along with src/commands/transport.ts, which joins the change here.
- No real device. I opened no audio or MIDI device, so the arm fix is verified by reading
armSetand by the daemon test of a refused set, which checks the daemon's state but cannot see the device in null mode.
The earlier findings, checked at this head:
- The refused arm (
player.cpp). Fixed. Both MIDI refusals, "no MIDI sources" and "cannot open any MIDI source", now return beforeopenAudioInputschanges the device. After a successful audio open nothing else can fail, becausecloseAudioInputruns only for a set with no audio.liveCompanionsis cleared only after that close, so a refused close keeps the arm before it whole. - The Windows test failures. Fixed.
publishskips onwin32,afterEachusesremoveTempProject, and the Windows job for this head, run 38117906465, passes this file's audio case and skips its four MIDI cases. That job fails the same 12 tests as the base branch's run and no others.
The arming plan is in-progress. This head answers nothing new and opens no question; §10 now points the file-bed punch-out at #194, which is open. The readiness gate holds.
What holds
- The arm. A set's MIDI inputs open unstarted and drop with no side effect when the audio open fails, and a refused set leaves
armedInputs,captureChannel, and the companion slots as they were. - The new status line.
field transport statusfalls back to the one-track fields whenstatus.record.armedis absent, so an older daemon reads as before, and a lone MIDI arm now prints its sources rather thanundefined input undefined. - The missing-take error.
field recordnames a track only after the recordings fallback has landed every complete take, so a take it names is incomplete on disk and--recoveris the command that finalizes it.
I ran pnpm install --frozen-lockfile, pnpm typecheck, and project check, which all pass; record-plan.test.ts and cliParsers.test.ts, 16 of 16; a Release field-audiod built from this head, with no warnings from native/audiod/src; and against it the record-tracks, record, record-midi, punch, click, and play daemon tests and src/audiod, 62 passed and 1 skipped, the no-source case this machine's MIDI service rules out. CI on Linux passes, and Windows fails only the base's 12.
ninjudd
left a comment
There was a problem hiding this comment.
📽️ Projector review · 0.7.4 · model claude-opus-5-5 · effort xhigh · CLEAN · took 0m 44s
This change lets field record arm and record several tracks in one pass, any mix of audio and MIDI, as chunk 2 of the arming plan. The CLI resolves every target before anything opens. The daemon keeps every capture rule on one primary track and adds up to 15 companions that the audio callback reads only through atomics. This head rewraps the arming plan's punch-out note, which the review of 6e2c0ec found too wide. It knowingly leaves loop takes to one track, MIDI routing to unison, the lasting arm to chunk 3, and plan criteria 6 to 8 to a hand test on a real interface.
3 finding threads: 3 resolved, 0 open
Covered 18 of 18 changed files; none are generated. The full diff was read at 9217fe4 and 6e2c0ec. Since 6e2c0ec, this head changes two lines of docs/projects/arming/readme.md and nothing else.
- Not rerun. I did not rebuild
field-audiodor rerun the daemon tests, because no file undernative/orsrc/differs from6e2c0ec. At6e2c0ec, a daemon built from the head passed the daemon tests (62 passed, 1 skipped), Linux CI passed, and Windows CI failed only the base branch's 12 tests. CI for this head was still running when this review posted. - No real device. No audio or MIDI device was opened at any head.
The earlier findings, checked at this head:
- The refused arm (
player.cpp). Fixed at6e2c0ec, and unchanged here. Both MIDI refusals return beforeopenAudioInputschanges the device, and nothing can fail after a successful audio open. - The Windows test failures. Fixed at
6e2c0ec, and unchanged here. The MIDI cases skip on Windows andafterEachusesremoveTempProject. - The plan's line wrapping. Fixed. Lines 261 and 262 are 69 and 67 characters, inside the paragraph's own width of 67 to 73, and the words match
6e2c0ec's exactly. No prose line in the plan runs past 80 characters.
The arming plan is in-progress, and this head adds no question; §10 points the file-bed punch-out at #194, which is open. The readiness gate holds.
What was checked
- The callback.
recordAudioBlock,recordMidiCompanions, andstampMidiBlockallocate nothing, take no lock, and do no I/O. The added work is a bounded loop over at most 15 slots. - The arm.
armSetopens MIDI sources unstarted before the audio device, so a refused set leaves the device,armedInputs,captureChannel, and the companion slots as they were. - Detach and finalize.
stopRecordingwaits two epochs before and after the detach, MIDI companions included. After a punch-out,serviceCapturefinalizes a companion only once the callback has cleared its pointer, in either order of the audio cut and the MIDI end. - The MIDI clock. Companions of an audio primary stamp against
midiUntilFrames, in the device's samples. OnemidiArrivalsLostexchange per block feeds every take'sdropped. - Crash safety. Each companion is its own transaction with its own journal, which
recordingslists as active andrecoverrefuses while it records. - Protocol and CLI. Every reader of
stop,record,arm, andstatus.recordtreats the new fields as optional.field recordnames any take that never landed with its--recovercommand, andfield transport statuslists every armed track. - Checks at this head.
project checkpasses.
field recordrecorded one track per pass, becausefield-audiodheld one arm. Singing and playing together, or two MIDI parts, took two performances. Justin asked on 2026-10-11 to record audio, MIDI, or both. This is chunk 2 of the arming plan (#189, which this is stacked on): name several tracks, and one pass records every one of them, each take starting on the same sample and landing on its own track.field recordnow takes any number of tracks.planArmresolves each to its record entry before anything opens, where its instrument decides MIDI or audio, and gives each audio track its--inputin the order named:--input 1,2, or 1, 2, and on by default. It refuses, with a message saying why:--input,--device, or--loopwhen every track records MIDI;--loopover more than one track.One track arms exactly as before. Several arm through the daemon's
armwithtracks, and every take that comes back lands, whether it arrives as an event, from the stop, or through the recordings fallback. If one take of several never arrives,field recordexits with an error naming the track and thefield record --recover <id>that finalizes it, as a single track's lost take always has.field transport statusin another terminal lists every armed track, a MIDI one by the sources it hears.The daemon was the real work. Rather than rewrite the capture path, which carries the latch, count-in, punch-out mid-block, and the loop hand-off, the first armed track is the primary, and every one of those rules runs on it unchanged. The other tracks are companions, in fixed slots the audio callback reads only through atomics, so the message thread can change a slot while it is not live and nothing on the audio thread allocates. Companions start on the primary's latch, an audio companion pushes the same span of its own input, and they end with the pass. An audio track is the primary whenever one is armed, so
--untilstill cuts audio on its exact sample. A MIDI take ends a block afteruntil, so that messages drained late are still stamped. That stamping is now one step: a MIDI primary's companions mirror it, and an audio primary's MIDI companions run it themselves, a block after the audio ends. The pass finalizes when every take has ended.armand the MIDI arm are one-entry forms ofarmSet, with their answers unchanged.armSetopens the MIDI sources, unstarted, before it touches the audio device, so a set refused for its MIDI or its audio leaves the device, and the arm before it, as they were.stopreturns every manifest astakesbesidetake.status.recordlistsarmedwhen more than one track is armed, and the MIDIsourceswhenever one of them records MIDI, so a one-track status is unchanged.recordingsandrecoverknow every take in flight. The null input presents each armed channel in order, which is how the tests tell input 1 from input 2.Docs follow the behavior.
docs/audio-engine.mdgains "Several armed tracks".docs/cli.mddescribes recording several tracks and gains thefield keysrow it never had.docs/keys.mdshows singing and playing in one pass. Plan §10 records the chunk. It also records something found along the way: an audio punch-out against a file bed ends 3 samples short ofuntil, with one track as with several, because a file bed's reported position runs a few samples ahead. That is older than this change, and #194 tracks it.Testing
From the repository root of this branch, after
pnpm install, with the native tools rebuilt from this branch (pnpm build:native; the daemon changed):The typecheck passes. The two focused files pass 8 of 8, and the full suite passes 1004 with 1 skipped (the no-MIDI-source case, which runs only without a MIDI service).
record-tracks-daemon.test.tsruns the daemon in null mode:field recordwith an audio and a MIDI track: it lands both on their own tracks,field transport statusnames both while they record, andfield checkis clean.The MIDI cases skip on Windows, which has no virtual MIDI ports, as
record-midi-daemon.test.tsdoes.The existing daemon tests (
record-daemon,punch-daemon,record-midi-daemon,click-daemon,play-daemon) all pass against the reworked daemon, which is the evidence that one track records exactly as before. A take holding the wrong input, two takes with different starts, or any of those older tests failing would mean the change is wrong.Nothing here played through a real interface. Plan criteria 6 to 8, two microphones on two inputs and a controller beside a vocal, are owed by hand. The tests leave nothing behind outside their temporary directories.
📽️ Projector summary of 30c7303: https://field.amnes.ac/reviews/191