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
+24 -17
View File
@@ -7,8 +7,8 @@ The base unit of signal production in Lyrebird.
```swift
protocol Generator: AnyObject {
var rate: ProcessingRate { get }
func calculatedSamples(graph: SynthGraph, count: Int) -> [[LyrebirdFloat]]
func floatValue(graph: SynthGraph) -> LyrebirdFloat
func calculatedSamples(graph: SynthGraph, count: Int) -> [[Double]]
func floatValue(graph: SynthGraph) -> Double
}
protocol AudioGenerator: Generator {} // rate == .audio
@@ -112,32 +112,39 @@ describe(OscSin.self) // Audio: OscSin.Audio Control: OscSin.Control
## Type Aliases
```swift
typealias LyrebirdFloat = Double
typealias LyrebirdInt = Int
typealias LyrebirdFloatClosureBody = (SynthGraph, Int) -> LyrebirdFloat
typealias ClosureBody = (SynthGraph, Int) -> Double // RT-safe closure signature
```
Samples are plain `Double` and counts plain `Int` — Lyrebird does not wrap them in aliases.
## ValidGeneratorInput Protocol
Enables seamless mixing of constants, generators, parameter keys, and closures as generator inputs. All of the following are valid:
Enables seamless mixing of constants, generators, and closures as generator inputs. All of the following are valid:
```swift
OscSin.Audio(freq: 440.0) // Float literal
OscSin.Audio(freq: someGenerator) // another Generator
OscSin.Audio(freq: "FreqParam") // string parameter key — resolved at runtime
OscSin.Audio(freq: { g, i in ... }) // closure
let someGenerator: OscSin.Control = OscSin.Control(freq: 2.0, mul: 10.0, add: 440.0)
let a: OscSin.Audio = OscSin.Audio(freq: 440.0) // Double literal
let b: OscSin.Audio = OscSin.Audio(freq: 60) // Int literal
let c: OscSin.Audio = OscSin.Audio(freq: someGenerator) // another Generator
let d: OscSin.Audio = OscSin.Audio(freq: Closure { graph, i in Double(i) }) // closure
```
To drive an input from a live parameter, wire a `@LiveParam`'s projected value (`$freq`, a
`ParameterNode`) into the generator. `String` is **not** a `ValidGeneratorInput` — the old
string-parameter-key input was removed when `ParameterNode` / `UIParamNode` became
`ControlGenerator`s.
```swift
protocol ValidGeneratorInput {
func calculatedSamples(graph: SynthGraph, count: Int) -> [[LyrebirdFloat]]
func floatValue(graph: SynthGraph) -> LyrebirdFloat
func intValue(graph: SynthGraph) -> LyrebirdInt
func calculatedSamples(graph: SynthGraph, count: Int) -> [[Double]]
func floatValue(graph: SynthGraph) -> Double
func intValue(graph: SynthGraph) -> Int
func needsInterpolation() -> Bool
func sampleBlock(graph: SynthGraph, count: Int, previousValue: LyrebirdFloat) -> [LyrebirdFloat]
func sampleBlock(graph: SynthGraph, count: Int, previousValue: Double) -> [Double]
}
// Conforming types: Double, Int, String, any Generator, Closure
// Conforming types: Double, Int, any Generator, Closure, GeneratorInputProvider
// Contract: calculatedSamples must always return a non-empty outer array (at least one channel).
```
@@ -199,7 +206,7 @@ mono-izes the generator under arithmetic.
When one or both operands are non-Generator literals (`Double` or `Int`), `BinaryOpGenerator`
uses `floatValue` instead of `calculatedSamples` for that side. This avoids the per-block
`[[LyrebirdFloat](repeating:count:)]` heap allocation that the `Double`/`Int` conformers would
`[[Double](repeating:count:)]` heap allocation that the `Double`/`Int` conformers would
otherwise produce. The classification is performed once in `init` and stored as `lhsIsLiteral`
/ `rhsIsLiteral` — no type-metadata checks on the RT thread.
@@ -251,7 +258,7 @@ is never violated in engine-driven usage. New generators **must** follow this pa
```swift
// Canonical new-generator calculatedSamples skeleton:
public func calculatedSamples(graph: SynthGraph, count: Int) -> [[LyrebirdFloat]] {
public func calculatedSamples(graph: SynthGraph, count: Int) -> [[Double]] {
precondition(count <= _result[0].count,
"count \(count) exceeds pre-allocated buffer. "
+ "Ensure blockSize <= lyrebirdDefaultResultBufferSize.")