Music XML updates and optimizations

This commit is contained in:
2026-06-16 20:55:32 -07:00
parent ca1ee503cc
commit 73191c958f
97 changed files with 5459 additions and 2031 deletions
+64
View File
@@ -7,6 +7,70 @@ functionality in a backward-compatible way.
---
## 1.1.1 — Real-time performance + score-timing fixes *(planned)*
A patch release: real-time CPU improvements to the synthesis engine's hot path,
internal generator consolidation, and two score-side timing fixes. Fully
backward-compatible — no public API changes.
### Real-time performance
The generator render path (`_computeSamples`) is now Accelerate-accelerated
where it was previously scalar. Wins are largest for the primitives that appear
in nearly every patch:
- **Unary math waveshapers** (`Sin` / `Cos` / `Exp` / `Log` / `Sqrt` / `Floor`
/ `Ceil` / `Abs`) — vectorized via vForce / vDSP (~3× faster on a typical
chained-op voice).
- **Arithmetic operators** (`+` `−` `×` `÷` on generators, via
`BinaryOpGenerator`) — vDSP dispatch, **bit-identical** to the scalar result
(divide uses true-division, never reciprocal-multiply). Roughly 2–3.5× faster;
applies to every `osc * gain + offset`-style graph.
- **`LinLin`** — single fused `vDSP_vsmsaD` affine map (~27% faster).
- **State-variable filter (`SVF`)** — shared per-block kernel; generator-driven
cutoff uses block-boundary coefficient interpolation instead of a per-sample
`sin()`.
- **`Chorus` / `Flanger`** — power-of-two delay lines (bitwise index wrap).
- **Butterworth band-pass / band-reject** — now use the same background-thread
vDSP biquad-cascade path the low-pass / high-pass filters already had.
All vectorized paths keep a scalar fallback for short upstream blocks, so output
is unchanged on every code path (transcendentals within tolerance; arithmetic
and filter sums bit-exact).
### Internals (no API impact)
- Generator consolidation: the duplicated Butterworth cascade machinery, SVF
block body, unary-math and binary-op inner loops, and power-of-two buffer
sizing are now shared helpers (`ButterworthSectionEngine`, `runSVFBlock`,
`UnaryMathVectorHelpers`, `BinaryOpVectorHelpers`, `lyrebirdNextPowerOfTwo`,
`computeButterworthQs`). Several hundred lines of duplication removed.
- New `LyrebirdBenchmark` target with before/after reference numbers
(`docs/benchmarks/gp-baseline.md`).
- Language-side consolidation: shared `isCounterExhausted` / `resetAll` Pattern
helpers, a `_RandomPatternBase` for the random pattern engines, a
`TemporalAlgorithmBase` for the counter-driven temporal algorithms, a shared
MusicXML `<direction>` / `<pitch>` emit helper, and a single
engine-mutation-to-main-queue dispatch helper shared by the routine/process
contexts.
### Score / MusicXML
- **`ScorePart` entrance offset** — a part can enter later than the start of its
section via `offset:` (`ScoreOffset.measures(_:)` / `.beats(_:)` /
`.fraction(_:)`). Resolved at build time into leading rests (the same way
`FillMeasure()` is resolved), so it flows through section sizing, MusicXML bar
splitting, and `flatten()` with no special handling.
- **MusicXML barline-fill fix** — corrected two emit-side defects in sectioned
scores with rest-padded short parts: a barline-crossing atom that exactly
filled a bar left the measure open (shifting every later note by one division,
rendering constant 4/4 as 5/4), and section auto-padding used meter-agnostic
rests that straddled barlines. Padding is now bar-grid aligned (clean
whole-measure rests; anacrusis-aware). Lowering/playback math was already
correct — both fixes are export-only.
---
## 1.1 — Enhanced algorithmic composition tools
Release 1.1 turns Lyrebird's score side from a thin event list into a full