v2.1.0 release: Swift 6.4 modernization

Typed throws across the closed-error-set APIs (OSC, MIDI, engine add/schedule,
bus/config/parameter, and the WAV/RF64/Spectral file codecs — source-compatible
narrowing, new .ioFailure cases), plus internal hardening: NSLock-guarded
scheduling/MIDI state moved to Mutex<State>, and the Spectral/FFT scratch owners
moved to a ~Copyable RTScratchBuffer RAII buffer. No API or behavioral change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-09-24 19:54:59 -07:00
parent 2c20b02e59
commit 844dc4d9cd
42 changed files with 835 additions and 640 deletions
+22
View File
@@ -1014,6 +1014,28 @@ A family of module-level free functions, base classes, and methods exist to elim
> **Out-of-tree extension packages:** these helpers are exposed as `@_spi(LyrebirdExtensions) public`. Add `@_spi(LyrebirdExtensions) import LyrebirdSynth` to any generator implementation file outside the core module. Full surface and stability policy: [extension-sdk.md](extension-sdk.md).
### `RTScratchBuffer<Element>` — single-owner RAII scratch buffer
`Buffers/RTScratchBuffer.swift`. A `~Copyable` heap buffer that replaces the
hand-paired `UnsafeMutablePointer.allocate` / `deinitialize` / `deallocate` a
scratch-owning generator otherwise repeats per buffer. The compiler guarantees it
is freed exactly once at `deinit` (with the right count) and can never be
copy-aliased; it carries no ARC and every accessor is `@inline(__always)`, so a
hot loop compiles to the same code as the raw pointer it replaces.
- `init(count:)` allocates + zero-fills (`Element: Numeric`); `init(count:repeating:)`
fills with any value (e.g. a unity gain table: `RTScratchBuffer(count: n, repeating: 1)`).
- Element access is `buffer[i]` (subscript; the setter is `nonmutating`, so a
`let`-held buffer is still writable — matching the raw pointer). Pass
`buffer.baseAddress` to vDSP / Accelerate / `memcpy`; for an offset use
`buffer.baseAddress + k` / `.baseAddress.advanced(by: k)`.
- **Must be a stored property assigned in `init`** — never a local inside
`process` / `_computeSamples`, which would allocate + free every render call.
- Not for `[UnsafeMutablePointer]`-style per-channel arrays (a `~Copyable` type
cannot be stored in an `Array`) nor for capacity-1 scalar boxes used via
`.pointee`; leave those on raw pointers.
- `@_spi(LyrebirdExtensions) public` — add the SPI import in out-of-tree files.
### `_resolvedInput()` — init-time resolution of `any ValidGeneratorInput`
Protocol requirement on `ValidGeneratorInput`. Default impl returns `self`; `GeneratorInputProvider` overrides to call its `make` closure and return a fresh `any ValidGeneratorInput`. Every Generator `init` that takes `any ValidGeneratorInput` parameters MUST call `_resolvedInput()` on each slot before storing or running `is any Generator` classification.