Skip to content

Land recorded takes: the record entry, takes.yaml, and placement on the track (recording.md chunk 2) - #167

Merged
ninjudd merged 2 commits into
mainfrom
recording-take-lands
Sep 7, 2026
Merged

ninjudd merged 2 commits into
mainfrom
recording-take-lands

Conversation

@ninjudd

@ninjudd ninjudd commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Chunk 2 of recording.md: a take the daemon finalized was a path under .field/recording/ after #166; now it is a take of the project. field record ends by landing it — the bytes move to audio/<node>/<take>.wav and pin in the song's ledger where imported audio pins, a row goes into audio/<node>/takes.yaml, the new take is chosen, the transaction is removed — and the next field build places it where it was sung.

The committed half

One bare entry, mirroring generative: with a person where the model was:

# songs/creek/tracks/lead-vocal.yaml
name: lead-vocal
inputs:
  - record:

Its record node is named like a gen node's (the track, or <track>-<id>), claims audio/<node>/ in the song's namespace the same way, and an entry with no takes yet builds as silence with check warning — input 1 ("record") has no takes yet — field record creek/track:lead-vocal — rather than refusing, so the mix can be placed and looped before the first take exists (plan §4). Takes with none chosen, a chosen name no row carries, a row whose asset is not in the ledger or whose bytes live outside audio/<node>/, a takes file naming another node, and a takes.yaml no entry claims are all errors.

The record

# songs/creek/audio/lead-vocal/takes.yaml
record: lead-vocal
chosen: take-20260907-110009
takes:
  - asset: take-20260907-110009
    started_at_samples: 120000
    musical_position: [3, 2]
    latency: 0
    device: "null"
    input: 1
    monitoring: apollo-direct
    console_preset: vocal-tracking
    recorded_at: 2026-09-07T11:00:09.190-04:00

The bytes pin in the ledger under the take's name, so the row carries the record and never a hash. started_at_samples is on the recording track's timeline, counted from the record entry's own at (zero for a bare entry), at the track's rate; latency is the device's declared round trip in the same samples; the take sounds at the entry's window start plus their difference and nothing else — musical_position is what the song's map said at capture and is never arithmetic.

Decisions worth arguing with (plan §13)

  • Placement is on the track's timeline, counted from the record entry's own at, converted once at landing. The daemon reports the start on the bed's timeline; landing subtracts the track's origin on the song (the ats summed down its first placement path from main, land.ts trackOrigin), scales bed samples to track samples, and subtracts the entry's window start — the same reading the graph makes when it adds that start back, so the entry's placement fields behave like every other kind's and moving the entry's at moves its takes. A track placed more than once records against its earliest placement and the take line says so; a track the song never places keeps its own timeline from zero. Rejected: storing the song position and resolving at build time, which would glue a take to the song and make it slide when the track moved. Known limit: track-local time: maps are not consulted on the origin walk.
  • Latency is input + output latency as declared. The reasoning is in §13.2; the loopback measurement §3 asks for is still owed to a hardware session, and the row is where a measured correction lands per take.
  • The graph expands the entry before planning (withTakes in graph.ts): an absolute audio: window over the chosen take at entry.at + started_at − latency, reading into the take when that is negative. Nothing downstream — planner, render, live compile, freeze — learns recording exists.
  • One record entry per track for now. A second would need the take to say which node it lands in.
  • field choose <song>/<node> --take <name> moves chosen; --variant and --take are exclusive.

import.ts gained openLedger/appendLedgerRow, which importAsset and landing now share; importAsset's behaviour and output are unchanged.

Testing

From the repo root (no native changes in this PR; the 0.12.0 daemon from #166 is what it drives):

pnpm build && pnpm test

47 files, 714 tests, green here. New: src/commands/land.test.ts (origin walk over nested and repeated placements, landing with a nonzero origin and latency, a take starting before the track, a record entry with its own at, rate conversion, refusals, chooseTake), the record entries block in src/model/project.test.ts (every diagnostic above, the namespace claim, canonical formatting), and the daemon end-to-end in record-daemon.test.ts now lands its take and builds the stem — silence to started_at_samples, the gapless sawtooth after.

By hand, null mode, in a scratch project:

mkdir /tmp/land-probe && cd /tmp/land-probe && export FIELD_AUDIOD_NULL=1
field init --name probe && field song create creek && field track create creek lead-vocal
node -e 'import("/Users/justin/amnesiac/field/dist/audio/wav.js").then(({ writeWavFloat32 }) => writeWavFloat32("tone.wav", 48000, [new Float32Array(48000*8).fill(0.1)]))'
field import tone.wav --song creek
printf 'name: main\ninputs:\n  - audio: tone\n    anchor: absolute\n    at: 0\n  - track: lead-vocal\n    at: [2]\n' > songs/creek/tracks/main.yaml
field record creek/track:lead-vocal                # refused: no `record:` entry
printf 'name: lead-vocal\ninputs:\n  - record:\n' > songs/creek/tracks/lead-vocal.yaml
field check                                        # warning: no takes yet; ok
field record creek/track:lead-vocal --at 3.2 --console-preset vocal-tracking   # ctrl-c after a few seconds
cat songs/creek/audio/lead-vocal/takes.yaml
field check                                        # ok, no warning
field build creek/track:lead-vocal && field explain creek/track:lead-vocal
field transport quit

The take line reads take creek/lead-vocal ← take-… at bar 3.2, chosen (audio/lead-vocal/take-….wav, N s). The row's started_at_samples should be 120000: bar 3.2 is 4.5 s into the song and lead-vocal sits at bar 2 (2 s), so 2.5 s on the track — before this branch there was no row, and a wrong origin subtraction shows up here as 216000. explain shows the stem's one clip at start: 120000. field record --list is empty afterwards because the transaction was removed; record a second take and field choose creek/lead-vocal --take <first name> moves chosen back.

On the Apollo, from examples/bloom: add - record: to songs/creek/tracks/lead-vocal.yaml's inputs, then field record creek/track:lead-vocal --input 1 --at 17 with the mix looping in another terminal, and field build creek && field play creek afterwards. What is wrong shows up as the vocal sitting late by the round trip — the latency on the row is the device's claim, and that is the loopback measurement still owed.

https://claude.ai/code/session_01CVAnQW78ZkZfxZ2GdKV886

…he track (recording.md chunk 2)

A take the daemon finalized was a path under .field/recording/; now it is a take of the project. `field record` ends by landing it: the bytes move to audio/<node>/<take>.wav and pin in the song's ledger where imported audio pins, a row goes into audio/<node>/takes.yaml, the new take is chosen, and the transaction is removed. `--recover` lands what it recovers and `--land <id>` covers a transaction nothing landed.

The committed half is one bare entry, `- record:`, mirroring `generative:` with a person where the model was. Its node is named like a gen node's, claims audio/<node>/ in the song's namespace the same way, and an entry with no takes yet builds as silence with `check` warning rather than refusing, so the mix can be placed and looped before the first take exists. The graph expands the entry into an absolute `audio:` window over the chosen take before a track is planned, so nothing downstream learns recording exists.

Placement is on the recording track's own timeline: landing subtracts the track's origin on the song — the `at`s summed down its first placement path from the output track — and the device's declared round trip, input plus output latency, converting both into the track's rate. That arithmetic is recorded on the row (`started_at_samples`, `latency`), where a loopback measurement on real hardware can correct it per take; the measurement itself is still owed.

`field choose <song>/<node> --take <name>` moves `chosen` the way `--variant` does. The plan records the decisions in §13.

Claude-Session: https://claude.ai/code/session_01CVAnQW78ZkZfxZ2GdKV886

@minjudd minjudd left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔭 Projector review · model claude-opus-5[1m] · effort xhigh · CHANGES REQUESTED · took 4m 00s

1 finding thread: 0 resolved, 1 open — this review opens it.

The one finding is below and it is worth the whole review: started_at_samples is written against one origin and read against another, so a record: entry that carries its own at: lands its take somewhere other than where field record says it did. Everything else here is in good shape.

State of the head. Based on e7f862b, which is current main, so this is the only open pull request in the repo that is not behind the Projector move. tsc --noEmit is clean and the full suite is 688 passed / 25 skipped / 0 failed. project check passes, the plan stays status: in-progress / priority: now without introducing new open questions — §11's five were all resolved or deferred in #166 and this diff does not reopen them — so there is no readiness flip to gate here. The three plan citations in the new files (recording.md §3, recording.md §4, project-layout.md §1.6) all resolve.

The schema reads well and the parts I checked hold. recordEntrySchema preprocesses a null to the empty table, which is the bare - record: spelling §11 settled on, matching how sendSchema already treats a bare label. started_at_samples is a plain signed integer while latency is min(0), which is the right asymmetry given the documented case of a take that starts before the window and reads into itself. musical_position is one to three elements each min(1), matching what MeterMap.position returns.

Ordering under crash is thought through. land.ts appends the ledger row, then the take row that names it, then removes the transaction — so a crash leaves an orphan file or a pinned asset no row names, never a row whose bytes are missing, which is the direction check can describe. It also refuses to write into a takes.yaml whose record: names a different node rather than merging blindly.

On what I could not check here: this diff does not touch native/, so the daemon binary I ran the suite against is the one main already carries; nothing in the C++ needed re-verifying for this head.

Comment thread src/commands/land.ts Resolved
… reads it

Landing wrote the row relative to the track's origin while the graph added the entry's own window start on top, so a `record:` entry carrying `at:` sounded somewhere other than where `field record` said it did — every test used a bare entry, where the window start is zero and the two readings agree (minjudd's finding on #167). The graph's reading stays: the entry's placement fields mean what they mean on every other kind, and moving its `at` moves its takes. Landing now subtracts the entry's window start under the track's map, and placedAt adds it back, so the take line, the row, and the clip agree. A test with `at: [3]` on the entry proves it both ways.

Claude-Session: https://claude.ai/code/session_01CVAnQW78ZkZfxZ2GdKV886

@minjudd minjudd left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔭 Projector review · model claude-opus-5[1m] · effort xhigh · APPROVED · took 2m 22s

1 finding thread: 1 resolved, 0 open.

888d33d is clean, and the origin mismatch is genuinely fixed rather than papered over — I re-ran the same reproduction that found it.

The fix works, measured the same way the bug was. With main placing vox at song zero, the record entry at bar 3, and a take the daemon started at bed sample 0:

reported placedAt      = 0
row.started_at_samples = -192000
graph clip start       = 0
AGREE?                 = true

Before, those read 0 and 192000. The row now carries -192000, which is the documented "started before the window, so the placement reads into the take" case rather than a special one, and placedAt is windowStart + startedAt - latency, which reduces to the same onTrack - latency the graph arrives at from the other direction. Both sides now compute one number.

You moved the writer rather than the graph, which is the side I would have argued for, and the reasoning now stated in record.ts and project-model.md — "Moving the entry's at moves its takes with it, as every other entry's content moves" — is what makes a record: entry's placement fields behave like every other kind's, which track.ts already promised they did.

I checked the two maps agree, since the fix depends on land.ts projecting the window exactly as graph.ts does. They match on every reachable case: with a track time:, both build from track.time.tempo at the track's rate; without one, both build from the song's events at the track's rate, and graph.ts's rate === songRate ? tempoMap : … branch is the same map either way. The third branch in land.ts — no tempo events anywhere — cannot disagree with anything, because graph.ts plans the whole song inside if (song.time) and mints no node at all without it.

The test you added is stronger than the one I asked for. I suggested a case with a non-zero at: on the record entry; land.test.ts now covers two takes across that window and checks the rendered stem bytes rather than the arithmetic — 216000 zero samples before the second take's first sample, at bar 3 plus a beat. That would catch a regression the assertions alone would not.

Docs moved with the code: the schema comment, project-model.md and the plan all now describe the same origin, so the next reader is not left reconciling three statements.

State of the head: tsc --noEmit clean, full suite 689 passed / 25 skipped / 0 failed, project check valid, plan still status: in-progress / priority: now with no new open questions.

What remains is a human approval. This is a COMMENT review carrying an approved verdict rather than a GitHub approval — the loop reports, it does not vouch. CI on this head had not reported when I submitted, so the green above is my local run; worth letting the linux job land first, as it was CI rather than my review that caught the meter bug on #166. Draft state untouched.

@ninjudd
ninjudd merged commit 7c84226 into main Sep 7, 2026
1 check passed
@ninjudd
ninjudd deleted the recording-take-lands branch September 7, 2026 22:28
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.

2 participants