Skip to content

Inserts and the master chain: effects in all three homes - #15

Merged
ninjudd merged 1 commit into
mainfrom
feat/inserts
Aug 5, 2026
Merged

ninjudd merged 1 commit into
mainfrom
feat/inserts

Conversation

@ninjudd

@ninjudd ninjudd commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Chunk 2 of effects.md §5, closing the phase's definition of done (§4).

What this adds

  • Track inserts: — a chain applied post-clip-sum inside track-render. Inserts are content: an insert edit re-renders the stem, while a fader move on the same track still cache-hits (tested side by side). A reverb insert grows the stem by its tail — creek's pad now rings past bar 9.
  • Mix master: — applied after the sum and the master gain, so a final limiter's ceiling guards the true output (gain drives into the limiter; the plan's original pre-gain wording was wrong and is fixed). Tested against +24 dB of deliberate drive.
  • Insert entries discriminated on effect: — the AU-era obligation from §1, honored in the schema from day one.
  • One DSP implementation, three homes — the standalone rules now route through the same applyInsertChain as inserts and the master chain; src/audio/insert-chain.ts is the reference implementation the live engine will be tested against.
  • Action-key preservation — specs omit inserts/master keys entirely when empty, so every pre-existing stem and mix keeps its action key: upgrading causes zero spurious rebuilds (the existing cache-hit tests prove it — all 157 prior tests pass unchanged).

Verified

  • 162 tests pass (5 new, listed in the commit).
  • field demo built and measured: kit clips play the EQ'd recipe (kit-punch chained off kit-sc), the pad's reverb insert extends its stem 3 s past the last clip, and mix:main's master limiter pins the true peak at exactly −1.00 dBFS — retiring the hand-tuned master gain from the mix-assembly era. One false alarm during verification worth recording: a probe window that read 22 dB low turned out to be the pad's own crossfade valley (release-into-attack), present before the insert — the DSP was right, the probe was mis-aimed.

field's matching commit (targets + inserts + master chain + README "Shaping" section) pushes alongside; the phase's definition of done — kit EQ'd, pad reverb'd, mix through a real limiter — is met.


Note

Medium Risk
Touches core render paths (track-render, mix) and cache keys; behavior is well-tested but wrong insert/master ordering would change audible output and rebuild scope.

Overview
Adds track inserts: and mix master: so EQ, limit, and reverb run in the same three places as standalone effect targets: post-clip-sum on stems and after stem sum plus master gain on mixes (so a master limiter actually caps the driven output).

applyInsertChain in src/audio/insert-chain.ts is the single DSP path; standalone eq / limit / reverb rules now delegate to one-entry chains instead of duplicating logic.

Schemas share effect parameters via insertSchema (discriminated on effect:). track-render and planMix only include inserts / master in build specs when non-empty, preserving action keys for existing stems and mixes without chains.

Docs update the build graph and project model for inserts-as-content vs fader-as-mix-stage caching, and mark effects chunk 1 shipped and chunk 2’s master ordering.

New inserts.test.ts covers stem re-render on insert edits vs fader-only cache hits, real EQ/reverb DSP, limiter after +24 dB master gain, and mix-only rebuild on master-chain edits.

Reviewed by Cursor Bugbot for commit fd419ee. Configure here.

Chunk 2 of effects.md: the same effect parameters now run as track
inserts (applied post-clip-sum - inserts are content, so an insert edit
re-renders the stem where a fader move never does) and as the mix master
chain, applied after the sum and the master gain so a final limiter's
ceiling guards the true output. Insert entries are discriminated on
effect: per the recorded obligation, ready for an au: variant. The
standalone rules now route through the same applyInsertChain, so one
implementation serves all three positions - the reference the live
engine will be tested against.

Specs omit the inserts/master keys entirely when empty, so every
pre-existing stem and mix keeps its action key - no spurious rebuilds on
upgrade. 5 new tests: insert DSP on stems, reverb tails growing stems,
insert-edit-rebuilds vs fader-still-cached, the master limiter holding
its ceiling against +24 dB of drive, and master edits re-running only
the sum.

@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.

Reviewed at head fd419ee (local checkout matches). Typecheck clean, all 162 tests pass, CI green (test + Bugbot). No findings. Every headline claim reproduced under independent execution.

Executed verification against this head:

  • "Zero upgrade cost" confirmed cross-commit — the strongest claim, so it got the worktree treatment: a project with effect-target chains, an insert-less stem, and a chainless mix built under the #14 engine came back fully cached under this head with zero executions. The omit-when-empty spelling (...(x.length > 0 ? … : {})) genuinely leaves every pre-existing action key byte-identical.
  • The limiter guards the true output, measured from the CLI — and both sides of the ceiling behave: a −26 dBFS source through gain_db: 24 into master: [limit @ −1] measures −2.021 dBFS (below ceiling → untouched, exactly source + gain), and through gain_db: 30 measures −1.000 dBFS (pinned). The corrected post-gain ordering is what makes the second number possible — and the plan-wording fix you caught is now recorded in §5 with the reasoning ("gain drives into the limiter").
  • 162/162 with the 157 prior tests untouched, matching the compatibility story.

Verified by reading, no issues found:

  • The ordering in both executors matches the recorded design exactly: stem = clips → sum → inserts (pre-fader), mix = stems → faders → sum → master gain → master chain. The limiter-last placement is structural, not conventional.
  • insert-chain.ts is a faithful unification — I diffed the standalone rules' old bodies against the chain's cases: byte-for-byte the same DSP calls, so #14's rendered artifacts are provably unchanged (the cross-commit cache hit on eq/reverb targets proves it at the hash level too, since their version stayed 1 — correct, because output bytes are identical).
  • Inserts/master land in parameters, not wiring — so an insert edit re-renders exactly its stem while a fader move still cache-hits (their side-by-side test), and explain will show the chain in the hashed parameters.
  • The effect: discriminator satisfies the §1 AU-era obligation additively; zod materializes defaults into specs, which means a future schema-default change correctly changes action keys rather than silently serving stale caches.
  • No new cycle surface: inserts are inline parameters, not references, so #14's cycle detector still covers the entire reference graph.
  • A reverb insert growing the stem composes safely downstream — the mix already pads shorter stems to the longest, so the tail ringing past the last clip is just a longer stem.

One small note from the smoke, in the PR's favor: the sub-ceiling case coming out untouched (not just "not clipped") is worth having — it confirms the limiter's leave-quiet-audio-alone property survives the chain plumbing.

This completes the effects phase's definition of done as §4 wrote it. Merging is Justin's checkpoint.

@ninjudd
ninjudd merged commit 6cff257 into main Aug 5, 2026
2 checks passed
ninjudd added a commit that referenced this pull request Aug 10, 2026
nested-tracks is Active — chunk 4 is revived by #123 and the soak
holds either way; Shipped was the one indefensible value. The three
stale prose lines are updated to what actually happened (voice
generation through #64/#65 and the #113 fold, effects through #14/#15
with the §6 executor move, musical time through #24), so the keyword
and the prose agree on day one. The README claims adoption, not
sharing, while agent-config#15 is still open.
@ninjudd
ninjudd deleted the feat/inserts branch September 28, 2026 04:10
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