v1.3.0 release: graceful-release fix, quickstart template + demo, documentation accuracy pass

- Fixed: SynthesizerBase subclasses' release/free now dispatch correctly (gated
  synths were hard-freed instead of released).
- New: quickstart project template + LyrebirdQuickstartDemo.
- Docs: every example typechecked or provably illustrative (426->542); ~20
  wrong-API examples fixed; root docs brought under the compile guard.
- Fixed: NRT/Score demo Package.swift build from terminal again.

See RELEASES.md for details.
This commit is contained in:
2026-07-17 14:05:01 -07:00
parent 63d6e0746f
commit 560724d116
149 changed files with 5010 additions and 1029 deletions
+19 -228
View File
@@ -2,18 +2,20 @@
Phases are ordered by dependency. Each phase should have tests before moving on.
Completed phases (1–34, 36–95, 96a, 97, 99, 101, 102a, 102b, 103, 104a, 104b, 104c, 104d, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 159, 160, 161, 162, 163, 170, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 196, 197, 198, 88b, MCE-A, MCE-B, 85.5, 86.75a, 86.75b, LyrebirdBufferUpdates, 77-review-cleanup, 71b, 49b, 46, iOS-1–iOS-4, Score Phases A–D, 204, 222, GC-1–GC-9B, GC-11, GC-12) are archived in `docs/01-completed-working-order.md`.
Completed phases (1–34, 36–95, 96a, 97, 99, 101, 102a, 102b, 103, 104a, 104b, 104c, 104d, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 159, 160, 161, 162, 163, 170, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 196, 197, 198, 88b, MCE-A, MCE-B, 85.5, 86.75a, 86.75b, LyrebirdBufferUpdates, 77-review-cleanup, 71b, 49b, 46, iOS-1–iOS-4, Score Phases A–D, 204, 222, GC-1–GC-9B, GC-11, GC-12, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239) are archived in `docs/01-completed-working-order.md`.
## Phase Completion Checklist
Before merging any phase branch to `main`:
1. All tests pass (`swift test`)
2. Run `/lyrebird_review` — no blocking findings
3. Fix any blocking issues found; re-run `/lyrebird_review` until clean
4. Merge to `main` with a `--no-ff` merge commit
5. `/lyrebird_review` updates `MEMORY.md` automatically on a clean pass
6. Move the completed phase section from this file into `docs/01-completed-working-order.md` (append at the bottom) and update the summary table below
1. All tests pass (`swift test --no-parallel` — the parallel runner has a known SIGABRT teardown flake)
2. If the phase touched a **public signature**, `.docc`, or doc comments: `bash scripts/check-docc.sh` (no new DocC warnings) **and** `bash scripts/check-doc-snippets.sh` (recorded doc examples still compile)
3. If the phase touched **`SynthesizerBase` / `Synthesizer` actor isolation**: `bash scripts/check-swift6-consumer.sh` — the test suite cannot catch isolation regressions (it doesn't build under `-default-isolation MainActor`)
4. Run `/lyrebird_review` — no blocking findings
5. Fix any blocking issues found; re-run `/lyrebird_review` until clean
6. Merge to `main` with a `--no-ff` merge commit
7. `/lyrebird_review` updates `MEMORY.md` automatically on a clean pass
8. Move the completed phase section from this file into `docs/01-completed-working-order.md` (append at the bottom) and update the summary table below
## Generator Authoring Rules
@@ -229,232 +231,21 @@ Full details in `docs/01-completed-working-order.md`.
| 228b | Parser meter round-trip — reads all `<time>` → `MeterMap` segments (sort, bar-1 guarantee, dedupe); `annotateBeams` per-measure capacity. Constant-meter byte-identical. Grouping re-inferred (MusicXML carries no grouping). | 4600 |
| 228c | Anacrusis (pickup) notation + round-trip — `<measure number="0" implicit="yes">` (capacity = `anacrusis`), full bars 1-based, both loops + `measureCount` + beam accounting; parser recovers `anacrusis`. No-anacrusis byte-identical. | 4611 |
| 229 | Polymeter notation — per-part `MeterMap` renders each part against its own meter (independent bar groupings/counts). Tests + `Meter`/`Polymeter`/`Beat timelines` docc + ScoreDemo material samples. Closes the beat-timeline group (223–229). | 4615 |
| 230 | Configurable `SynthesisEngine.maxEventsPerBlock` (was hard-coded 256) — the per-block firing + carry-over look-ahead budget; threaded through `SynthesisEngineConfig`/`EngineHost`. RT-safe drop telemetry (`perBlockEventDropCount`) + one-line console warning drained off-RT (`freeWorker`/`stop()`/NRT post-render). `docs/engine/scheduling.md`. | 5456 |
| 231 | `LyrebirdRoutineContext.onMain(_:)` — construct `@MainActor` synths inside a `@Sendable` routine/task body (result carried out of the main hop via a box; the shared bridge is `Void`-returning). Threading/isolation documented in `ARCHITECTURE.md` §9.2 + linked from GettingStarted / RoutineTask docs; records why `SynthesizerBase.init` cannot be `nonisolated` (MainActorConsumer fixture). | 5460 |
| 232 | Doc sweep + DocC warning ratchet — `scripts/check-docc.sh` gates new DocC warnings against a 62-entry baseline (links pin full signatures; nothing else checks them). Fixed actively-wrong docs (SPSCQueue "rounds up" → traps; nonexistent `schedule(.remove:)`; `Package.swift` docc target), 11 `engine.add` examples missing `try`, and SynthesisEngine init/threading/NRT drift. | 5460 |
| 233 | DocC link repair — 62 → 5 warnings. Score API grew params (`spanners:`, `meterMap:`, `normalType:`, `tie:`, `measureBarlines:`…) and DocC links pin full signatures, so every older link broke. Updated links; converted permanently-ambiguous overloads (`Chord`, `fill`, `dbToAmp`) and `internal` symbols to plain code. 5 article/symbol collisions left (DocC bug, IA decision). | 5460 |
| 234 | DocC catalog to zero warnings — converted 5 filename-colliding articles (`SendTrigger`, `SpectralChain`, `StepSequencer`, `ValueComputable`, `GeneratorInputProvider`) into documentation extensions, so each guide merges into its symbol's page instead of shadowing the API reference. Baseline now empty; the gate is effectively strict. | 5460 |
| 235 | Killed the three hand-copied API mirrors (`SynthesizerProtocol`, `GeneratorProtocol`, `EngineSetup`) — all three had already drifted — replacing them with gate-verified symbol-link tables; removed 75 references to the deleted `LyrebirdFloat`/`LyrebirdInt` types from live docs. | 5460 |
| 236 | Doc-example compile harness — `check-doc-snippets.sh` typechecks doc fences against the real API via `swiftc -typecheck` + `#sourceLocation` (failures point at the .md line). Checked set classified by the compiler, not by hand: 323 of 1457. | 5460 |
| 237 | Doc-example fallout — fixed `GettingStarted`'s flagship example (`doneAction`/`.freeEnclosing` never existed), made entry examples self-contained (coverage 382/1458; the original `try` rot now fails), harness `throws` wrapper + narrowest-first preambles, and pinned `DistributionKind`'s golden values (3 of 4 had drifted). | 5465 |
| 238 | Doc-rot gap pass — extended the DocC gate to `LyrebirdUI` (was entirely unguarded; 0 warnings), implemented the `member` preamble (396 → 426 fences), confirmed zero remaining dead API forms, and established that the residual 1032 fences are continuation fragments no preamble can fix. | 5477 |
| 239 | Doc checks in the review process — `check-doc-impact.sh` reports which docs a diff's public-API changes may have invalidated (validated against the commit that caused the original `engine.add` rot). Reports, never fails; suppresses refs the compile guard already covers; wired into `/lyrebird_review` step 2b. | 5477 |
---
## Upcoming Phases
### Beat-Timeline / Time-Signature group (Phases 224–229)
Goal: let authors place notes at explicit beat positions on a part timeline and
auto-fill the rests (the `VoiceGenerator.from((1.0, Note…), (5.0, Note…))`
request), with a real time-signature model underneath (compound, complex/
additive, anacrusis, mid-piece meter changes, eventual polymeter).
Design decisions (locked with Josh):
- **One internal truth** = 0-based quarter-note beats (matches `ScoreEvent.beat`,
tuplet math, engine). All musician-friendly addressing resolves down to it.
- **`beatGrouping` is the primitive.** A `TimeSignature` carries a partition of
the numerator into beats in denominator-note units. Auto-inferred, but
explicitly overridable: `6/8` defaults compound `[3,3]` but can be made simple
`[1,1,1,1,1,1]` (slow 6/8); additive `8/8` as `[3,3,2]` gives a 3+3+2 pulse.
`isCompound` = "any group > 1". No special-casing — compound math falls out of
the grouping data.
- **Meter scope:** `Score.meterMap` is the global default; `Part.meterMap?` is an
all-or-nothing override (nil = inherit; non-nil = a *complete* replacement map).
A part can NOT patch a segment of the score map. `MeterMap` itself is segmented
`[(startBar, TimeSignature)]`.
- **Anacrusis:** `anacrusis: Fraction` (pickup length in quarters). Quarter `0.0`
= pickup start; first full barline at `anacrusis`; pickup = bar 0 (`implicit`);
bar 1 = first complete measure. Existing 1-based `TempoChange`/`Ending` measure
refs stay bar ≥ 1 (pickup excluded).
- **Overlap policy:** default traps loud + signals — throws a descriptive
`TimelineError.overlap(at:previousEndsAt:incoming:)` (catchable, also routable
to `LyrebirdMessageCenter`). Not a silent fix.
- **Polymeter:** allow in the model from Phase 224 (cheap — the placement/`flatten`
path is meter-map-driven, gets polymeter free); defer the hard *notation*
(per-part non-aligning barlines, per-part encoder measure loop) to Phase 229.
No retrofit — staged fill-in, not a rewrite.
#### Phase 224 — `TimeSignature` + `MeterMap` model ✓ *(complete — see `01-completed-working-order.md`)*
#### Phase 225 — `ScoreTimeline.fill` (quarter-beat addressing) + shared rest-fill ✓ *(complete — see `01-completed-working-order.md`)*
#### Phase 226 — `BeatPosition` (musical addressing) + meter-aware resolver ✓ *(complete — see `01-completed-working-order.md`)*
#### Phase 227 — Overlap policies + multi-voice timelines ✓ *(complete — see `01-completed-working-order.md`)*
#### Phase 228 — Homometric mid-piece meter changes (encoder) ✓ *(complete — see `01-completed-working-order.md`)*
#### Phase 228b — Parser meter round-trip + per-measure beams ✓ *(complete — see `01-completed-working-order.md`)*
#### Phase 228c — Anacrusis notation + round-trip ✓ *(complete — see `01-completed-working-order.md`)*
#### Phase 228.5 — Drop phase-number references from code/docs ✓ *(complete)*
- Swept `Phase NNN` references from all source comments, doc-comments, `.docc`
prose, `@Suite` strings, and test file/type/function names (59 files). Renamed
`Phase60ScatterCollectionTests`/`Phase57NoiseTests`/`Phase201IsolationGuardTests`.
- New CLAUDE.md hard rule **"No phase numbers in code or docs"** (under Swift
Code Style Rules → review-flagged) enforces it for code-writing + review agents
going forward. DSP term "phase" exempt.
#### Phase 229 — Polymeter notation ✓ *(complete — see `01-completed-working-order.md`)*
Per-part meter already rendered correctly once the encoder went per-part for
mid-piece meter changes (`part.meterMap ?? score.meterMap`, parts encode
independently) — so this was tests + docs + ScoreDemo material samples, not a
structural lift. **The beat-timeline / time-signature group (223–229) is
complete.**
New work beyond this group is scoped from the **Deferred / Future** and **Not
planned** lists below as demand appears.
### Generator Consolidation + RT Performance group (GP-1 … GP-9)
Goal: collapse remaining duplicated per-sample / per-init Generator code into
shared helpers, and land a set of benchmark-gated real-time performance wins on
the audio render path (`_computeSamples` / `calculatedSamples`). Sourced from an
architecture sweep of `Sources/Lyrebird/Generators/` + `GeneratorCore/`.
Splits into two work-streams: **dedup** (no behaviour change, gated on tests
only) and **perf** (gated on before/after benchmark + tests + review). Each
phase is its own branch off `main` per the standing phase-branch policy.
**Locked decisions (with Josh):**
- **vDSP/vForce strategy = split-path, keep scalar fallback.** Each vectorised
generator branches on `n == count` (upstream block full-length — the normal
case at *any* block size, including small control blocks like 64). Only the
rare short-upstream-block case (`n < count`) falls to the existing scalar
loop. The vDSP/vForce call fires for 64-sample control blocks too — the gate
is upstream-fullness, not absolute block size. If benchmarks show vDSP call
overhead losing at *tiny* counts (1/2/4), add a `count >= minVectorCount`
threshold (strictly better than "vDSP everywhere"). Revisit a
"vDSP-everywhere + zero-pad" variant only if the split-path data warrants it.
- **Benchmark harness = existing `Sources/LyrebirdBenchmark/main.swift`.** Add
one timed case per perf phase (`ContinuousClock`, warmup + N timed iters,
reports ns/block + ns/sample; `OfflineDriver` for in-context `processBlock`).
Run release only: `swift run -c release LyrebirdBenchmark`. The control-block
sweep (512 → 1) already in the harness shows the win-curve across block sizes.
- **Per-phase gate.** Dedup phases: `swift test --no-parallel` green +
`/lyrebird_review` clean. Perf phases: same, *plus* a committed before/after
benchmark delta; keep the change only if it shows a real win with no test
regression. Capture baseline numbers in the phase branch's first commit.
#### Phase GP-0 — Benchmark baseline capture
Add timed cases to `LyrebirdBenchmark` for every perf target *before* touching
code: `BinaryOpGenerator` (scalar-mul, vector-add), unary math (`Sin`/`Exp`/
`Sqrt`/`Abs`), `LinLin.Audio`, SVF generator-driven `freq`, `Chorus.Audio`.
Run the control-block sweep on each. Commit the baseline numbers as the
reference all GP perf phases diff against. No production code change.
#### Phase GP-1 — Trivial / low-risk dedup (no perf risk) ✓ *(complete — merged to main)*
Pure consolidation, semantically identical, gated on tests + review only:
- **D1** — Merge byte-identical `normalizeLFPhase` / `normalizeBLPhase` into one
`normalizeOscPhase(_:)` helper. 8 oscillator `.Control` callers
(LF/Osc Sawtooth/Square/Triangle/DutyCycle).
- **D7** — Add `lyrebirdTwoPi` to `Math/LyrebirdConstants.swift`; replace 5
inline `let twoPi = 2.0 * .pi` locals (Chorus/Flanger/Phaser/Jitter/
ScannedSynthesizer). Removes magic-number-rule smell on the hot path.
- **D4** — Adopt existing `resolveGeneratorOrScalar(...)` in `Chorus`/`Flanger`/
`Phaser._computeSamples` — replaces ~17 hand-rolled 8-line input-resolution
blocks. Helper already proven in Flute/Clarinet/Pan*/PlateReverb.
- **D2** — Extract `computeButterworthQs(order:) -> [Double]` (new
`Filters/ButterworthHelpers.swift`); 4 Butterworth filters call it at init.
#### Phase GP-2 — SVF helper extraction + coefficient interpolation (D6 + P4) ✓ *(complete — merged to main; −5.9% on gen-driven-freq bench)*
Bundles a dedup and a perf win that touch the same code:
- **D6** — Extract `runSVFBlock(...)` (Chamberlin recurrence + denormal flush +
zero-fill); `SVF.Audio` and `SVF.Control._computeSamples` collapse to setup +
one call + `mulAdd`. Name `svfMinQDamping` / `svfFCoeffMax` constants.
- **P4** — In the generator-driven-`freq` path, replace per-sample
`Darwin.sin(piOverSr·freq)` with block-boundary `fFirst`/`fLast` + linear
interpolation (same technique as `runRBJBiquadBlock`). Eliminates ~510 of 512
`sin` calls/block on that path. Benchmark the gen-driven-freq case.
Gate: tests + review + benchmark (perf component).
#### Phase GP-3 — Butterworth LP/HP cascade engine extraction (D3) ✓ *(complete — merged to main; ~250 dup lines removed, behavior-identical)*
- **D3** — Extract shared background-thread vDSP cascade machinery
(`runScalar`/`runVDSP`/`runAudioRate`/deinit drain + the `_vdsp*Queue` set)
into a `ButterworthCascadeEngine` in `ButterworthHelpers.swift`. LP and HP
inject two coefficient closures and become thin wrappers. Removes ~250 lines
of duplicated thread lifecycle. Medium risk — match the thread teardown
exactly. Gate: tests + review. Sets up GP-9.
#### Phase GP-4 — Unary math vForce/vDSP fast path (P3) ✓ *(complete — merged to main; −66.9% / ~3× on the 4-op unary chain)*
- **P3** — Split-path vectorisation for `Sin`/`Cos`/`Exp`/`Log`/`Sqrt`/`Floor`/
`Ceil` (`vvsin`/`vvcos`/`vvexp`/`vvlog`/`vvsqrt`/`vvfloor`/`vvceil`) and
`Abs` (`vDSP_vabsD`). `n == count` → vectorised; `n < count` → existing scalar
loop. No allocation (write into pre-zeroed `_result`). Highest single-generator
throughput win (~4–10×). Benchmark each across the control-block sweep; apply
`minVectorCount` threshold if tiny blocks regress.
#### Phase GP-5 — `BinaryOpGenerator` enum dispatch + vDSP (P2) ✓ *(complete — merged to main; gen×gen −56%, gen×scalar −72%)*
- **P2** — Replace the stored `op: (Double,Double)->Double` closure with an
operator enum (`.add`/`.subtract`/`.multiply`/`.divide`) classified at init;
dispatch aligned gen-vs-gen / gen-vs-scalar paths to `vDSP_vaddD`/`vsubD`/
`vmulD`/`vdivD`/`vsaddD`/`vsmulD`. Keep the per-sample closure fallback for
non-arithmetic / unaligned-count cases. Highest *graph-wide* win — every
`osc * 0.5 + env` chain. Preserve IEEE-754 divide-by-zero behaviour. Medium
risk — enumerate all variants, keep closure escape hatch. Benchmark scalar-mul
+ vector-add cases.
#### Phase GP-6 — `LinLin` vDSP fast path (P7) ✓ *(complete — merged to main; −26.9%. LinExp/ExpLin deferred)*
- **P7** — `LinLin.Audio` → single `vDSP_vsmsaD` (`a·x + b`, coefficients
hoisted out of loop; range params are always block-scalar so unconditional).
Short-block fallback keeps the exact per-sample formula.
- *Deferred:* `LinExp`/`ExpLin` (build the linear stage via vDSP then `vvexp` —
needs a pre-allocated scratch buffer at init; modest incremental win, revisit
if a profile flags them).
#### Phase GP-7 — Power-of-two delay-line wrapping (P5) ✓ *(complete — merged to main; Chorus −3.3%)*
- **P5** — `Chorus`/`Flanger` circular delay lines: size up to next power of two
at init, replace per-sample `% delayLineCount` (3–4 per sample) with
`& (delayLineCount - 1)`. ~2× delay-buffer memory (≈64 KB at max delay) for
~6–9 cycles/sample saved. Add init-time `roundUpToPowerOfTwo(_:)`. Benchmark
`Chorus.Audio`.
#### Phase GP-8 — Butterworth band-pass / band-reject vDSP cascade (P6) ✓ *(complete — merged to main; shared ButterworthSectionEngine, BP/BR gain vDSP + dedup)*
- **P6** — Extend the GP-3 `ButterworthCascadeEngine` vDSP path to
`ButterworthBandPass` (sequenced HP→LP) and `ButterworthBandReject` (parallel
LP+HP summed via `vDSP_vaddD`). Matches the LP/HP acceleration. Depends on
GP-3. Band-reject needs two vDSP setups + dual kill-queue drain. Benchmark a
4th-order bandpass.
**Sequencing:** GP-0 (baseline) → GP-1 (safe dedup) → GP-2/GP-3 (helper
extractions, GP-3 before GP-8) → GP-4/GP-5 (highest-value perf) → GP-6/GP-7 →
GP-8. Each lands on `main` via `--no-ff` before the next starts, per policy.
**Not pursued:** D5 (`OscSin.Audio` inlined switch) — intentional audio-rate
choice (three branchless loops vs per-sample function call); leave as-is, revisit
only if `OscillatorTableReadHelpers` gains a bitmask-wrap variant.
### Generator Catalog Expansion — 1.2 (SuperCollider parity gaps) ✓ *(complete)*
Closed the most-noticed UGen gaps relative to SuperCollider (trigger/timing
logic, control-signal conditioning, filters, waveshaping/routing, chaotic
oscillators, analysis). **The whole 1.2 group is complete** — GC-1…GC-9B, GC-11,
and GC-12 merged to main; GC-10 (`DFM1`) skipped on license grounds (GPL source +
baked GPL LUT). All phase records are archived in
`docs/01-completed-working-order.md` (§ Generator Catalog Expansion — 1.2).
`TGrains` and `PingPongDelay` were explicitly excluded from this group (deferred
separately).
### Longer-term — Not planned
#### Phase 96b — Ableton Link *(not planned)*
Ableton Link SDK integration for peer-to-peer beat sync over LAN/WiFi was
scoped but will not be built. MIDI Clock follow (Phase 96a, complete on `main`)
is the supported external-transport path. Revisit only if real demand appears;
the SDK-vendoring cost (C++ SwiftPM target, abl_link FFI shim, Bonjour
entitlements, 2-device test bench) is not justified otherwise.
---
## Deferred / Future