Repository navigation
Plan cross-rate live wiring: dirty tracks convert at the edge, devices convert at delivery - #141
Conversation
…s convert at delivery Realtime decision 7's owed piece, scoped and decided: a clean cross-rate child already rides the freeze (multi-rate's convert nodes are ordinary file deps), so the plan covers the two real gaps — a dirty conversion whose source is live evaluates the child at its own rate and converts the materialized buffer through the offline wrapper (bit-identity by construction), and a device that cannot switch to the session's rate gets a streaming-resampler delivery instead of a refusal. Both refusal messages retire; SESSION_VERSION bumps because track rates become load-bearing at edges. Streaming rings stay deferred.
|
Starting review of c398ac1. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c398ac1925
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
minjudd
left a comment
There was a problem hiding this comment.
Reviewing c398ac1. The description says the load-bearing observation is that most of the work already exists, and names what would show the plan wrong, so I built the fixture and probed the claims rather than reading them.
The graph half of §1 is exactly right, including the spelling. On a 48 kHz project with a 44.1 kHz child:
diagnostics: 0 total, 0 errors
convert nodes: //songs/opener/convert:track-low-48000
main deps: //songs/opener/convert:track-low-48000
main depends on the minted conversion, not on the child — the label is the one §1 names, character for character, and the fixture checks clean.
The compile half does not exist, and that is the finding. The same fixture is refused by compileSession, cold and warm alike, because the all-tracks rate check reads every track in the song rather than the ones the session reaches. Details on the thread; the short version is that "the freeze already covers the clean case" has never been true, so the plan opens by crediting the freeze with a case it cannot reach.
The falsification target the description names holds up. §2.2's max(1, round(n·to/from)) in reduced-ratio integer arithmetic is resample.cpp:202's flush exactly — (inN * phases + stride / 2) / stride with phases/stride gcd-reduced by ratioFor, then floored at one. It differs from the code in one case only, which is on its own thread.
The rest of the citations resolve. The session.ts quote is verbatim (it wraps across lines 10–12, so it does not grep as one string — worth saying because it looks missing at first). dsp::Resampler and the resample() wrapper are both in resample.h as described, and the wrapper's passthrough short-circuit is real. RESAMPLER_TAPS = 128 makes decision 3's taps/2 ≈ 1.4 ms right at 44.1 kHz (64/44100 = 1.45 ms). Both relative links resolve.
The conventions are right. status: Draft on a plan not yet started, sections numbered so citations survive, and the now.md line rides the same diff with a hook rather than a summary. Decision 4's reasoning is the strongest thing in the plan: an old daemon summing a cross-rate session raw is precisely the quietly-wrong-monitor case the version exists to catch, and it is the kind of thing that is invisible until someone hears it.
No code moved, so the description's "pnpm test stays green (40 files / 608 tests)" carries from the merge it sits on rather than needing a re-run: git diff --stat 67a431c..c398ac1 -- . ':!docs' is empty, and I ran 608 green at d3d6c52, whose tree the merge preserved.
Three threads, all on the plan's account of the tree rather than on its decisions — the five decisions themselves I think are right, and decision 1's bit-identity-by-construction argument is the correct one to reach for.
…urce, the converter's lifecycle minjudd measured the claim the plan led with and it was false: no cross-rate session has ever compiled, clean or dirty — the all-tracks rate check refuses the song before the freeze could serve the cached conversion — so §1 now says what actually exists (the graph routing) and counts three gaps, cheapest first. The refusal count is three, not two: the engine's own constructor guard joins the list and decision 1 names its replacement. The output-length rule gains its empty-source branch (zero in, zero out — the #57 lesson the floor-at-one exists for). The delivery converter gets a specified lifecycle across locate, stop, swap, and natural end, plus a recorded heard-position bound. And realtime.md decision 7 gains the amendment reconciling its delay-compensation clause with the aligned materialized edge.
|
Starting review of b4909be. |
minjudd
left a comment
There was a problem hiding this comment.
Approving b4909be. All three findings are closed, and the §1 rewrite went past correcting the sentence to correcting what the plan is for.
§1 now says the thing that was missing. "No cross-rate session has ever compiled, clean or dirty" is the honest version, and keeping the routing credit beside it — "That routing is genuinely most of the hard part" — is right rather than penitent: the minted edge really is the hard part, it just is not the whole path. Renaming the section to "what only looks like it does" makes the distinction the reader's first impression instead of a correction buried mid-paragraph. Reordering the gaps cheapest-first is the useful consequence, since unblocking the clean case is a deletion and now visibly the place to start.
The third refusal is named where it belongs — three places, not one. The Goal lists it with its stale "later in chunk 2" message, §4 counts three, and decision 1 says the guard "retires with the edge conversion that makes it unnecessary", which is the part that matters: it ties the removal to the thing that makes removal safe rather than listing it as one more deletion.
The output-length rule is now exact, and quoting the #57 lesson beside it means the next person to read the formula learns why the branch exists rather than tidying it away.
The two DSP claims this round leans on are true, and I measured both rather than reading them. Decision 1's "the wrapper's emission is timeline-aligned" is the load-bearing one, so I put an impulse through the real resample op:
input impulse at 1000 @ 44100 Hz
aligned position would be 1088; group-delayed would be ~1152
peak found at 1088 (offset from aligned: 0)
input frames 4000 -> output frames 4354; rule says 4354
Zero offset, so emission carries no group delay into the timeline, and the corrected length rule predicts the frame count exactly. That settles the realtime.md amendment too: decision 7's "reported into delay compensation" really did describe an edge this engine never runs, and the amendment is a correction rather than a reinterpretation.
The citations resolve, including the two that hide from grep. resample.h:63's delay, set to taps / 2 at resample.cpp:133 and gating emission at :185, is the internal accounting decision 1 points at. Decision 7's quoted clause is real — it wraps across realtime.md lines 120–121, so "reported into delay compensation" does not grep as one string, the same trap as the session.ts quote in the last round. Both are quoted accurately.
Decision 3's lifecycle addition is the kind of thing plans usually leave for the implementer to discover. Naming what locate, stop, swap and natural end each do to the converter — and recording the bounded skew so nobody reads it as a bug later — is worth more than the decision it is attached to. engineBlock is 512, so one conversion block plus taps/2 is ~12 ms at 48 kHz; ~15 ms is a fair ceiling.
Conventions hold. Sections still number 1–4 with the amendment nested inside realtime.md's decision 7, so nothing renumbered and no citation broke. status: Draft is still correct — §3 flips it to Active when the implementation PR opens. Dropping "implementation is one PR behind it" from now.md removes a line that would have gone stale the moment that PR opened.
No code moved this round either, so the suite claim still carries from the merge underneath rather than needing a re-run.
No findings.
…#142) Freeverb was chunk 1 of realtime's fastest correct port, and it sounds like it: a static tail (no modulation, so sustained material rings the combs metallically), echo density that never grows, and stereo that is one network offset 23 samples. This plans its two successors as new insert effects — `plate`, Jon Dattorro's 1997 figure-8 tank taken whole (published topology, published tunings scaled from 29 761 Hz the way Freeverb's already scale), and `hall`, a Jot feedback delay network: eight mutually-prime delay lines under a Householder matrix, whose per-band decay exposes directly what a damping knob euphemizes (`decay: 3.5, decay_low: 1.3, decay_high: 0.4` reads like how rooms actually behave). Freeverb stays, deliberately: with no users and only the example project, replacement would be cheap, but a kept `reverb` is a permanent A/B — same send, three effect names, difference audible in one edit under the live watch — and that comparison was judged worth more than the tidiness of deleting it. Both effects inherit realtime.md's constraints and the plan says how each is met: causal, deterministic, and block-size invariant (decision 3), analytic tails for the compiler's chain-growth arithmetic (plate: predelay + T60; hall: the longest band governs), and denormal-safe without flushing (decision 6). The interesting one is modulation — the thing Freeverb lacks and the reason plates shimmer — kept golden-clean by construction: LFO phase is a pure function of the absolute sample index, seeded by locate with the position it lands on, so a seek hears exactly what a from-the-top render would, block partitioning cannot move a bit, and `modulation: 0` is bit-frozen for the harness. Each chunk bumps RENDER_PLAN_VERSION (a new effect is the listed reason that version exists) and grows the session insert union, with the old daemon's fail-closed parse doing what it is for. Existing songs rebuild as pure cache hits — action keys never move. Convolution reverb (impulse responses as committed assets — a real place in the repo, hash-pinned like any asset — but needing a cross-platform-deterministic FFT before it can join the golden) and the exotic architectures (velvet-noise, scattering delay networks) were ranked in the same discussion and land as later.md lines, not chunks. Two chunks, one per effect, plate first: streaming class + whole-buffer wrapper + analytic tail, schema/session/plan arms on both sides, dsp-check block-invariance and subnormal cases, golden byte-identity — and the definition of done is the demo the realtime engine was built for: `field play creek --watch` with the shared room's insert flipped between `reverb`, `plate`, and `hall`, three rooms A/B'd live, the ear deciding what creek ships with. **Testing** Docs only — nothing builds or runs differently. `pnpm test` from the repo root stays green (40 files / 608 tests). Read the plan at `docs/projects/all/reverbs.md`; the claims worth probing: §2.4's determinism argument for modulated delays against realtime.md decision 3's block-invariance requirement (the LFO-phase-from-sample-index construction is the whole answer, so a hole in it sinks chunk 1), §2.5's tail formulas against the compiler's existing chainGrowth reverb arm in `src/graph/live.ts`, and decision 1's cache claim against the rule that new insert types touch no existing action key. Note this branch shares a `docs/projects/now.md` edit region with #141 (both add a line to the list); whichever merges second takes a one-line rebase. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Documentation-only changes to project planning files; no runtime, schema, or build behavior changes in this PR. > > **Overview** > Adds **`docs/projects/all/reverbs.md`**, a draft plan for two new insert effects—**`plate`** (Dattorro figure-8 tank) and **`hall`** (Jot FDN with per-band decay)—while keeping existing **`reverb`** (Freeverb) for live A/B. The doc locks six decisions: realtime constraints (deterministic modulation via sample-index LFO phase, analytic tail growth beside **`chainGrowth`** in `src/graph/live.ts`, cache law), example YAML, two implementation chunks, and a definition of done centered on **`field play creek --watch`**. > > **`docs/projects/now.md`** adds a line committing the reverbs work. **`docs/projects/later.md`** adds deferred lines for convolution IR reverb and exotic architectures, both pointing back to reverbs §1. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ffb6ccc. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Realtime shipped with three recorded debts; this plans the first — cross-rate live wiring, decision 7's "a foreign-rate dirty track therefore runs live like every other track" — and commits it in now.md. Streaming rings stay deferred per the discussion that scoped this.
The plan's load-bearing observation is that the hard routing already exists — and the review corrected how much. Multi-rate minted the edge: a parent placing a cross-rate child depends on a
convert:node, not the child, verified on a fixture (48 kmain→convert:track-low-48000→ 44.1 ktrack:low, zero diagnostics). But no cross-rate session has ever compiled, clean or dirty: the all-tracks rate check refuses the song before the freeze could serve the cached conversion as a file window (minjudd measured it — cold and warm both refused). So the gaps are three, cheapest first: unblock the clean case by deleting that check, and then the two this plan is really about. A dirty conversion whose source is live: today it would build synchronously inside the compile — the re-render-and-swap cliff decision 7 explicitly rejected, currently hidden behind the compile-time refusal — so instead the child evaluates live at its own rate and the engine converts the materialized child buffer wholesale through the offlineresample()wrapper: the same kernel on the same samples the offline node would see, bit-identity by construction, no group delay because the future exists (the same availability-not-shift reasoning that keeps comp_delay zero). And the device: when it cannot switch to the session's rate, delivery converts through the streamingdsp::Resamplerinstead of refusing — what the artifact path's transport always did, now with the project's own kernel, outside the golden as delivery always was.All three refusal messages retire (the compile refusal, the engine's own constructor guard against a foreign-rate session track — whose message still says this wiring lands "later in chunk 2" — and the daemon's device refusal with its artifact-spelling rescue), SESSION_VERSION bumps to 2 because track rates become load-bearing at edges (an old daemon summing a cross-rate session raw would be quietly wrong — exactly what the version exists to prevent), and the watch's dirty list speaks convert labels for cross-rate children so the background freeze converges one node deeper. One chunk: a single implementation PR follows this plan, flipping the status Draft → Shipped when it lands, since the chunk is the plan.
Testing
Docs only — nothing builds or runs differently.
pnpm testfrom the repo root stays green (40 files / 608 tests). Read the plan atdocs/projects/all/cross-rate-live.md; the claims worth probing against the tree:rg -n 'convert:' src/graph/graph.tsshows the minted edge nodes §1 leans on,rg -n 'cross-rate|foreign rate' src/graph/live.ts native/audiod/src/live.cpp native/audiod/src/player.cppfinds the three refusals the Goal retires, and the fixture in §1 reproduces with a 44.1 kHz asset imported--allow-mismatchinto a 48 kHz song withrate: 44100on the placing track. What would show the plan wrong: a reading of resample.cpp's flush arithmetic that disagrees with §2.2's output-length rule (the review already sharpened its empty-source branch), or a reason a materialized-buffer conversion could diverge from the offline convert node's bytes.