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
+56 -3
View File
@@ -10,6 +10,10 @@ import Foundation
/// Template style for a scaffolded Lyrebird project.
public enum ProjectTemplate: String, CaseIterable, Equatable {
/// The shortest path to sound: a one-oscillator `SineTone`, the engine, and a
/// `main` that plays a 440 Hz tone for ten seconds and exits. The fastest way
/// to hear Lyrebird after installing the CLI.
case quickstart = "quickstart"
/// Minimal engine setup with `CoreAudioDriver` and `RunLoop.main.run()`.
case basic = "basic"
/// Real-time demo: `SineTone` synthesizer with `@LiveParam` frequency and amplitude.
@@ -34,6 +38,8 @@ public enum ProjectTemplate: String, CaseIterable, Equatable {
/// Case-insensitive init from a raw string. Accepts hyphen-free aliases too.
public init?(string: String) {
switch string.lowercased() {
case "quickstart", "quick-start", "quick":
self = .quickstart
case "basic": self = .basic
case "demo": self = .demo
case "ui-demo", "uidemo", "ui_demo": self = .uiDemo
@@ -58,7 +64,7 @@ public enum ProjectTemplate: String, CaseIterable, Equatable {
/// SwiftPM can express.
public var shipsXcodeProject: Bool {
switch self {
case .basic, .demo, .uiDemo, .nrt, .score: return false
case .quickstart, .basic, .demo, .uiDemo, .nrt, .score: return false
case .macosUIXcode, .iosUI, .auv3: return true
}
}
@@ -303,7 +309,7 @@ public enum ProjectScaffolder {
case .auv3:
try writeAUv3Files(name: name, projectRoot: projectRoot,
lyrebirdPath: lyrebirdPath, fm: fm)
case .basic, .demo, .uiDemo, .nrt, .score:
case .quickstart, .basic, .demo, .uiDemo, .nrt, .score:
// Unreachable — shipsXcodeProject filters these out at dispatch.
try? fm.removeItem(atPath: projectRoot)
throw Error.fileSystemError(
@@ -349,6 +355,8 @@ public enum ProjectScaffolder {
static let scaffoldDefaultOutputChannels: Int = 2
static let scaffoldDefaultInputChannels: Int = 2
static let scaffoldDefaultNRTDuration: Double = 4.0
/// Seconds the `quickstart` template plays its sine tone before exiting.
static let scaffoldQuickstartDurationSeconds: Double = 10.0
// MARK: - Package manifest
@@ -375,7 +383,7 @@ public enum ProjectScaffolder {
// the dep is local or remote.
let targetDeps: String
switch template {
case .basic, .demo, .nrt, .score:
case .quickstart, .basic, .demo, .nrt, .score:
targetDeps = #""Lyrebird""#
case .uiDemo:
targetDeps = #""Lyrebird", .product(name: "LyrebirdUI", package: "Lyrebird")"#
@@ -432,6 +440,7 @@ public enum ProjectScaffolder {
template: ProjectTemplate = .basic
) -> String {
switch template {
case .quickstart: return mainSwiftQuickstart(name: name)
case .basic: return mainSwiftBasic(name: name)
case .demo: return mainSwiftDemo(name: name)
case .uiDemo: return mainSwiftUIDemo(name: name)
@@ -445,6 +454,50 @@ public enum ProjectScaffolder {
}
}
// MARK: quickstart (the shortest path to sound)
private static func mainSwiftQuickstart(name: String) -> String {
"""
// \(name) — quickstart: the shortest path to sound.
//
// Run it: lyrebird run (or `swift run`)
// You'll hear a 440 Hz sine for \(Int(scaffoldQuickstartDurationSeconds)) seconds, then it exits.
import Foundation
import LyrebirdSynth
// A Synthesizer is a graph built in `build()`. This one is a single sine
// oscillator, scaled down so it isn't harsh, centred to both speakers
// with Pan2 and written to output bus 0 (left) / bus 1 (right).
final class SineTone: SynthesizerBase {
override func build() {
output(bus: 0, source: Pan2(input: OscSin.Audio(freq: 440.0) * 0.2))
}
}
do {
// The engine owns Core Audio and runs the graph on the RT thread.
let engine = SynthesisEngine(
blockSize: \(scaffoldDefaultBlockSize),
sampleRate: \(scaffoldDefaultSampleRate),
numOutputChannels: \(scaffoldDefaultOutputChannels),
numInputChannels: 0,
driver: CoreAudioDriver()
)
try engine.start() // opens the output device
try engine.add(SineTone()) // starts sounding immediately
print("\(name): playing a 440 Hz sine for \(Int(scaffoldQuickstartDurationSeconds)) seconds…")
Thread.sleep(forTimeInterval: \(scaffoldQuickstartDurationSeconds))
engine.stop() // closes the device
print("Done.")
} catch {
fatalError("Lyrebird quickstart failed to start: \\(error)")
}
"""
}
// MARK: basic
private static func mainSwiftBasic(name: String) -> String {