diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 27147b1..c0ac0d5 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -256,12 +256,14 @@ And `engine.remove(synth)`: `remove` returns `Bool` (it unbinds synchronously on successful enqueue), but there is a documented one-`processBlock` window between `remove` and a re-`add` of the same instance — the RT thread needs a block to actually unlink it. If `freeQueue` overflows, the framework logs one warning and leaks that single reference rather than risk the RT thread; a leaked voice is preferable to an audio dropout or crash. -### 9.1 Actor isolation of the lifecycle (Phase 201) +### 9.1 Actor isolation of the lifecycle The Swift-concurrency isolation of `Synthesizer` is split along exactly the thread boundary above: - **Language side is `@MainActor`.** `SynthesizerBase` is a `@MainActor` class, and the `Synthesizer` protocol declares `build()`, `release(engine:)`, `free(engine:)` as `@MainActor` requirements. Steps 1–4 of the add path (allocate → build → enqueue) and the `engine.add` / `schedule` / `add(position:)` entry points are therefore main-actor-isolated. This is what lets a consumer building under Xcode 26's `SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor` default subclass `SynthesizerBase` and override `build()` with **no** concurrency annotations — the consumer's MainActor default now matches the base instead of conflicting with a nonisolated override. (`engine.remove` stays nonisolated — it unbinds via atomics and enqueues a pointer-only event; `_bind` / `_unbind` are nonisolated for the same reason.) +- **`SynthesizerBase` declares `release(engine:)` / `free(engine:)` as `open` members, not just protocol conformances.** The `Synthesizer` extension supplies defaults for both, but a protocol-extension default is bound **statically** at the conformance — `SynthesizerBase`'s. Were the base to declare no member of its own, a subclass could not `override` them at all, and a subclass method declared without `override` would be invisible to every caller holding an `any Synthesizer`: the call would reach the extension default and throw `.noGate`. That matters because the callers that drive the lifecycle are exactly those existential ones — `Group.release` cascades to children as `any Synthesizer`, freeing any child that throws `.noGate`, so a gated subclass would be hard-freed and its envelope release phase skipped. Declaring both as `open` class members makes the witness a class method, so the call dispatches through the vtable and subclass overrides run. Pinned by `SynthesizerReleaseDispatchTests`. + - **The RT entry point is `nonisolated`.** `evaluate(graph:count:)` is `nonisolated final` so the render callback (steps 5–6) reaches it with **no actor hop**. It reads exactly two stored properties cross-thread — `parameterTable` (immutable `let`) and `outputGenerators` (written in `build()` on main, read on RT) — both marked `nonisolated(unsafe)`. Their safety rests entirely on the happens-before edge established by the SPSC `pendingQueue` (§2.1): the RT thread cannot observe the node until it dequeues the `.add` event, which the producer enqueued *after* `build()` fully returned on main. No new runtime synchronisation is introduced by the isolation annotations. - **`Group` / `ParallelGroup` stay nonisolated.** They satisfy the `@MainActor` `build`/`release`/`free` requirements with less-isolated (nonisolated) witnesses, keeping their RT-owned linked-list / snapshot state reachable from the render thread. `Group.release` installs its self-free poll timer through a `nonisolated` helper so the utility-queue handler does not inherit `@MainActor` (which would trap when it fires off-main). @@ -270,6 +272,48 @@ The Swift-concurrency isolation of `Synthesizer` is split along exactly the thre The guarantee is locked by the committed `RegressionFixtures/MainActorConsumer` package, which compiles an unannotated `SynthesizerBase` subclass under `.swiftLanguageMode(.v6)` + `-default-isolation MainActor`. +### 9.2 Working with the isolation from a routine or task + +A `LyrebirdRoutine` / `LyrebirdTask` body is `@Sendable` and runs on its own background thread. `SynthesizerBase` is `@MainActor`. Those two facts drive every ergonomic question below, so it is worth being precise about **what is actually main-bound, and why**: + +| Step | Main-bound? | Why | +|---|---|---| +| `init` (allocate the synth) | **Yes** — but for an *ergonomic* reason, not an RT one | See "Why `init` is not `nonisolated`" below | +| `build()` (construct the DAG) | **Yes — load-bearing** | Must complete-before the `.add` enqueue; that is the happens-before edge the RT thread relies on (§9.1) | +| `engine.add` / `schedule` | **Yes — load-bearing** | `pendingQueue` is SPSC: exactly one producer | +| `engine.remove` | No | Unbinds via atomics, enqueues a pointer-only event | +| Writing a `@LiveParam` | No — but the *property* is main-isolated | The value itself crosses via a lock-free atomic (see "Mutating parameters") | +| `evaluate()` (RT) | No — `nonisolated final` | The render callback must reach it with no actor hop | + +**Constructing a synth inside a body — `ctx.onMain`.** Because a body cannot touch `@MainActor` state directly, the historical idiom was to pre-allocate every synth *outside* the body and capture it (the `BufferDemos` pattern). That forces the set of synths to be known in advance. ``LyrebirdRoutineContext/onMain(_:)`` removes the restriction — it runs a main-actor closure, blocks the body until it returns, and hands the (possibly non-`Sendable`) result back: + +```swift +LyrebirdTask.run(engine: engine) { ctx in + while ctx.now < 10.0 { + let grain: Grain = ctx.onMain { Grain(startPos: nextPos(), rate: nextRate()) } + ctx.add(grain) // async hop; grain self-frees via its envelope + try ctx.wait(seconds: 0.05) // drift-compensated as usual + } +} +``` + +The hop is synchronous, so its cost counts as work between `wait` calls — which `wait(seconds:)` already compensates for by shortening the next sleep. Keep the closure short (build one synth, not a batch): it blocks both the body and the main thread. Note `build()` does **not** run inside `onMain` — it runs later, on main, inside `ctx.add`'s dispatched `engine.add`. + +`onMain` **requires a serviced main thread**, and this is the one way to misuse it. `ctx.add` is fire-and-forget (`DispatchQueue.main.async`) and merely delays if main is busy; `onMain` hops synchronously with no timeout, so if main is never serviced it blocks the body forever with no diagnostic. A GUI run loop services it; so does a CLI parked on `waitUntilComplete()` / `LyrebirdTask.run`, which pump the main run loop for exactly this reason. The trap is `task.start(engine:)` followed by blocking main on something that is not a run loop (a bare `Thread.sleep`, a semaphore wait) — park on `waitUntilComplete()` instead. Re-entering the caller's own thread is *not* a hazard: `lyrebirdRunMainActorMutation` branches on `Thread.isMainThread` and runs the closure inline when already on main, so `onMain` is self-deadlock-free whichever thread calls it. + +**Mutating parameters — `ctx.set`, not property writes.** Construction is *pre-publication*: the synth is thread-local, unshared, and the RT thread cannot reach it, which is what makes hopping to main for it a pure formality. A parameter write is *post-publication*: the synth is live in the tree and the RT thread reads it every block. Safety there comes from `ParameterNode`'s atomic — **not** from isolation. So capture the projected node on main once, then drive it from the body: + +```swift +let cutoff: ParameterNode = filter.$cutoff // captured on main +LyrebirdTask.run(engine: engine) { ctx in + ctx.set(cutoff, to: 1200) // releasing atomic store — no dispatch +} +``` + +`ctx.set` is **not** a main hop: unlike `ctx.add`, it writes the atomic inline on the body's own thread. The only cost is the one-line capture. (`synth.cutoff = 1200` and `synth.$cutoff` are both main-isolated — the property inherits the class's isolation even though `LiveParam` itself is a plain, atomic-backed struct.) + +**Why `init` is not `nonisolated`.** It looks free — the base `init()` is empty, `build()` is not called from it, and a fresh synth is unshared. It is not free. Under `-default-isolation MainActor` a consumer subclass that declares no init gets an *implicit `@MainActor init()`*, which would then override a `nonisolated` base init and fail with `different actor isolation from nonisolated overridden declaration` — breaking every unannotated consumer, i.e. exactly the §9.1 guarantee. The main test suite cannot catch this (it does not build under that flag); `RegressionFixtures/MainActorConsumer` is the only thing that does. **If you are tempted to relax the isolation on `SynthesizerBase.init`, build that fixture first.** `ctx.onMain` exists precisely because it buys the same ergonomics additively, with no isolation change. + --- ## Where to go deeper diff --git a/CLAUDE.md b/CLAUDE.md index 483c451..9f6ce02 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -31,6 +31,23 @@ git config core.hooksPath .githooks ``` The `.githooks/pre-commit` hook calls `--check`. Skips silently when `~/.claude/agents/` is absent (contributors without working copies are not blocked). Bypass for one commit with `git commit --no-verify`. +## Repo Guard Scripts + +These guards catch classes of regression that **`swift build` / `swift test` structurally cannot**. Both are manual/CI (too slow for pre-commit). Run before a release or a merge that touches their surface. + +| Script | Guards | Run when | +|---|---|---| +| `bash scripts/check-swift6-consumer.sh` | The zero-annotation consumer guarantee — builds `RegressionFixtures/MainActorConsumer` under `.swiftLanguageMode(.v6)` + `-default-isolation MainActor`. The main package **does not build under that flag**, so the test suite cannot catch an isolation regression. | Any change to `SynthesizerBase` / `Synthesizer` actor isolation. Non-negotiable: `swift test` passing is *not* evidence here. | +| `bash scripts/check-docc.sh` | New DocC warnings — broken symbol links, ambiguous refs, article/symbol collisions. DocC links pin a symbol's **full signature**, so adding one parameter silently breaks every link to it. Nothing else checks this. | Any change to a public signature, or edits to `.docc` / doc comments. | +| `bash scripts/check-doc-impact.sh [range]` | **Reports** (never fails) which docs a diff's public-API changes may have invalidated. Doc rot is usually *caused* by an API change, and a diff-only read cannot find the stale references — they live in files the diff never touches. Run by `/lyrebird_review` step 2b; suppresses refs the compile guard already covers. | Any change to a public signature. | +| `bash scripts/check-doc-snippets.sh` | Doc **examples** that stop compiling. `swift build` never sees a code fence and `check-docc.sh` only validates links, so examples rot silently — `engine.add` became throwing and 11 examples kept calling it without `try`; `LyrebirdFloat` was deleted and 75 references outlived it. Both are type errors, so the fences are typechecked against the real API. | Any change to a public signature, or edits to `.docc` / doc comments. | + +`check-docc.sh` is a **ratchet**: it fails on warnings absent from `scripts/docc-warnings-baseline.txt`. That baseline is now **empty** — the catalog is at zero warnings — so in practice any new warning fails the build. Keep it that way; the baseline may only shrink. (`--strict` asserts zero explicitly and is equivalent while the baseline is empty. `--update-baseline` exists for the rare deliberate exception — prefer fixing the link.) + +**Golden values need a test, not a guard.** A typecheck proves an example still *compiles*; it cannot see a documented result drift. Where a doc asserts concrete output (`// → 0.744, 0.046, …`), pin it with a test — `DistributionKindGoldenValueTests` and `_DocTheorySnippetCheckTests` are the two instances. This is not optional pedantry: three of the four `DistributionKind` sequences had silently drifted, and their fences also passed a `seed:` argument to a type that has no such parameter. + +`check-doc-snippets.sh` checks the fences recorded in `scripts/doc-snippets-manifest.txt` (currently **426** of 1458). That set is produced by asking the **compiler** which fences compile — `--classify` — never by hand-annotating fences. A fence that compiles under no preamble self-excludes, which is how iOS-only examples, `Package.swift` snippets and pseudo-code drop out with no skip list. **Coverage is therefore partial by construction**: a fragment like `try engine.add(MySynth())`, which needs both an `engine` and a `MySynth` in scope, is *not* checked. The fix for an important uncovered example is to make it self-contained in the doc — which is better documentation anyway — not to grow the preamble table. Re-run `--classify` after adding examples or deliberately changing what is checkable. + ## Task → Doc Map **Engine / RT core** diff --git a/Demos/LyrebirdDemo/LyrebirdDemo/Demos/BufferDemos.swift b/Demos/LyrebirdDemo/LyrebirdDemo/Demos/BufferDemos.swift index 20de493..1fd89fb 100644 --- a/Demos/LyrebirdDemo/LyrebirdDemo/Demos/BufferDemos.swift +++ b/Demos/LyrebirdDemo/LyrebirdDemo/Demos/BufferDemos.swift @@ -17,7 +17,7 @@ final class BufferDemos: DemoProtocol { func runDemo() { // BufferDemos.swift lives at .../Demos/LyrebirdDemo/LyrebirdDemo/Demos/BufferDemos.swift - // — 4 components up to reach .../Demos/ where Perc.aiff lives. + // — 4 components up to reach .../Demos/ where Mozart.aiff lives. let percURL: URL = URL(fileURLWithPath: #filePath) .deletingLastPathComponent() // .../Demos/ .deletingLastPathComponent() // .../LyrebirdDemo/ @@ -37,10 +37,6 @@ final class BufferDemos: DemoProtocol { let sampleRate: Double = engine.sampleRate - // SynthesizerBase is @MainActor-isolated. LyrebirdTask.run's body is @Sendable and - // non-async, so synth inits must happen BEFORE the closure on the main thread. - // runDemo() is reached from main.swift on the main thread, so assumeIsolated is valid. - let pitchSteps: [(Double, String)] = [ (0.5, "0.5 — octave down"), (0.75, "0.75 — minor third down"), @@ -70,27 +66,23 @@ final class BufferDemos: DemoProtocol { (0.33, "0.33 — 3× compression (triple speed, pitch preserved)"), ] - // Pre-construct all synthesizers on the main actor before entering the @Sendable closure. - let (demo1, demo2, demo3, pitchRatioNode, demo4Array, demo5Array, demo6Array): - (PercPlayBuffer, PercBufferRead, PercPitchShift, ParameterNode, - [PercSpectralPitchShift], [PercSpectralStereoDiffuse], [PercTimeStretch]) = - MainActor.assumeIsolated { - let d1: PercPlayBuffer = PercPlayBuffer(buffer: percBuffer, engineSampleRate: sampleRate) - let d2: PercBufferRead = PercBufferRead(buffer: percBuffer) - let d3: PercPitchShift = PercPitchShift(buffer: percBuffer, engineSampleRate: sampleRate) - let prNode: ParameterNode = d3.$pitchRatio + // `runDemo()` is @MainActor (see DemoProtocol), so the @MainActor synths are constructed + // directly — no `MainActor.assumeIsolated` wrapping. Build them here, then hand the + // resulting instances / live-param node to the @Sendable task body. + let demo1: PercPlayBuffer = PercPlayBuffer(buffer: percBuffer, engineSampleRate: sampleRate) + let demo2: PercBufferRead = PercBufferRead(buffer: percBuffer) + let demo3: PercPitchShift = PercPitchShift(buffer: percBuffer, engineSampleRate: sampleRate) + let pitchRatioNode: ParameterNode = demo3.$pitchRatio - let d4: [PercSpectralPitchShift] = spectralRatios.map { ratio, _ in - PercSpectralPitchShift(buffer: percBuffer, pitchRatio: ratio, engineSampleRate: sampleRate) - } - let d5: [PercSpectralStereoDiffuse] = diffuseSteps.map { amount, _ in - PercSpectralStereoDiffuse(buffer: percBuffer, amount: amount, engineSampleRate: sampleRate) - } - let d6: [PercTimeStretch] = stretchSteps.map { factor, _ in - PercTimeStretch(buffer: percBuffer, stretchFactor: factor) - } - return (d1, d2, d3, prNode, d4, d5, d6) - } + let demo4Array: [PercSpectralPitchShift] = spectralRatios.map { ratio, _ in + PercSpectralPitchShift(buffer: percBuffer, pitchRatio: ratio, engineSampleRate: sampleRate) + } + let demo5Array: [PercSpectralStereoDiffuse] = diffuseSteps.map { amount, _ in + PercSpectralStereoDiffuse(buffer: percBuffer, amount: amount, engineSampleRate: sampleRate) + } + let demo6Array: [PercTimeStretch] = stretchSteps.map { factor, _ in + PercTimeStretch(buffer: percBuffer, stretchFactor: factor) + } LyrebirdTask.run(engine: engine) { ctx in // Demo 1 — PlayBuffer (looping at native rate) @@ -112,8 +104,7 @@ final class BufferDemos: DemoProtocol { ctx.add(demo3) for (ratio, label) in pitchSteps { print(" pitchRatio \(label)") - // Update via ParameterNode.value — nonisolated atomic setter, RT-safe. - pitchRatioNode.value = ratio + ctx.set(pitchRatioNode, to: ratio) // live-param write from the task body try ctx.wait(seconds: 3) } ctx.remove(demo3) diff --git a/Demos/LyrebirdDemo/LyrebirdDemo/Demos/DemoProtocol.swift b/Demos/LyrebirdDemo/LyrebirdDemo/Demos/DemoProtocol.swift index c237561..12e40be 100644 --- a/Demos/LyrebirdDemo/LyrebirdDemo/Demos/DemoProtocol.swift +++ b/Demos/LyrebirdDemo/LyrebirdDemo/Demos/DemoProtocol.swift @@ -7,5 +7,10 @@ import LyrebirdSynth protocol DemoProtocol { - func runDemo() + /// Main-actor-isolated: demos construct `@MainActor` `SynthesizerBase` synths and are launched + /// from `main.swift`'s top-level code (which runs on the main actor). Isolating the requirement + /// lets conformances build synths and read their `$liveParam` nodes directly — no + /// `MainActor.assumeIsolated { … }` wrapping — before handing Sendable references to a + /// background `LyrebirdTask`/`LyrebirdRoutine` body. + @MainActor func runDemo() } diff --git a/Demos/LyrebirdDemo/LyrebirdDemo/Demos/ReverbDemo.swift b/Demos/LyrebirdDemo/LyrebirdDemo/Demos/ReverbDemo.swift index 11cb7d3..525c923 100644 --- a/Demos/LyrebirdDemo/LyrebirdDemo/Demos/ReverbDemo.swift +++ b/Demos/LyrebirdDemo/LyrebirdDemo/Demos/ReverbDemo.swift @@ -19,19 +19,29 @@ final class ReverbDemo: DemoProtocol { let sampleRate: Double = engine.sampleRate - // SynthesizerBase is @MainActor-isolated. Pre-construct the synth on the main actor - // before entering the @Sendable LyrebirdTask closure. runDemo() is reached from - // main.swift on the main thread, so assumeIsolated is valid. - let reverbDemo: GVerbTest = MainActor.assumeIsolated { - GVerbTest(sampleRate: sampleRate) - } + // `runDemo()` is @MainActor (see DemoProtocol), so the @MainActor synth is constructed and + // its live-param node read directly + let reverbDemo: GVerbTest = GVerbTest(sampleRate: sampleRate) + // `$reverbTime` is a Sendable `ParameterNode` — capture it here, then write it from inside + // the @Sendable task body (GVerb picks up each change on the next block). The @MainActor + // `reverbDemo.reverbTime` property itself is NOT reachable from the task body under Swift 6; + // the node is. either grab it outside the task (uncomment below) ... + // let reverbTimeParam: ParameterNode = reverbDemo.$reverbTime + LyrebirdTask.run(engine: engine) { ctx in ctx.tempo = 60.0 ctx.add(reverbDemo) - try ctx.wait(beats: 6) // could also use seconds + // ... or use ctx.onMain inside the task + let param: ParameterNode = ctx.onMain { + reverbDemo.$reverbTime + } + try ctx.wait(beats: 2) // hold the starting reverbTime (3.0) + ctx.set(param, to: 8.0) // step: jump to a long tail + try ctx.wait(beats: 2) + try ctx.ramp(param, to: 0.5, beats: 2) // glide: smooth swoosh down to a short tail ctx.remove(reverbDemo) - print("\nAll buffer demos complete.") + print("\nAll reverb demos complete.") } } } diff --git a/Demos/LyrebirdDemo/LyrebirdDemo/Synthesizers/GVerbTest.swift b/Demos/LyrebirdDemo/LyrebirdDemo/Synthesizers/GVerbTest.swift index 50b72b0..5560f4d 100644 --- a/Demos/LyrebirdDemo/LyrebirdDemo/Synthesizers/GVerbTest.swift +++ b/Demos/LyrebirdDemo/LyrebirdDemo/Synthesizers/GVerbTest.swift @@ -14,17 +14,21 @@ import LyrebirdSynth final class GVerbTest: SynthesizerBase { + // A live parameter: `$reverbTime` is a `ParameterNode` (Sendable) that GVerb re-reads every + // block, so writing `reverbTime`/`$reverbTime.value` retunes the running reverb. Change it from + // the main thread or a `LyrebirdTask`/`LyrebirdRoutine` body — see `ReverbDemo`. + @LiveParam var reverbTime: Double = 3.0 private let sampleRate: Double - + init(sampleRate: Double) { self.sampleRate = sampleRate } - + override func build() { let impulse = Impulse.Audio(freq: 0.5) let reverb = GVerb.Audio(source: impulse, roomSize: 70.0, - reverbTime: 3.0, + reverbTime: $reverbTime, // live ParameterNode, not the baked scalar earlyLevel: 0.4, tailLevel: 0.9, dryLevel: 0.1, diff --git a/Demos/LyrebirdDemo/LyrebirdDemo/main.swift b/Demos/LyrebirdDemo/LyrebirdDemo/main.swift index 15ebb43..015ff3e 100644 --- a/Demos/LyrebirdDemo/LyrebirdDemo/main.swift +++ b/Demos/LyrebirdDemo/LyrebirdDemo/main.swift @@ -9,7 +9,7 @@ import LyrebirdSynth let engine = SynthesisEngine( blockSize: 512, - sampleRate: 48000, + sampleRate: 44100, numOutputChannels: 2, numInputChannels: 2, driver: CoreAudioDriver() @@ -22,6 +22,7 @@ do { exit(1) } -BufferDemos(engine: engine).runDemo() -//ReverbDemo(engine: engine).runDemo() +// BufferDemos(engine: engine).runDemo() +ReverbDemo(engine: engine).runDemo() + engine.stop() diff --git a/Demos/LyrebirdDemo/Package.swift b/Demos/LyrebirdDemo/Package.swift index f6196eb..3f67df0 100644 --- a/Demos/LyrebirdDemo/Package.swift +++ b/Demos/LyrebirdDemo/Package.swift @@ -17,7 +17,7 @@ let package = Package( .executableTarget( name: "LyrebirdDemo", dependencies: [ - .product(name: "Lyrebird", package: "LyrebirdII"), + .product(name: "Lyrebird", package: "Lyrebird"), ], path: "LyrebirdDemo" ), diff --git a/Demos/LyrebirdMacOSDemo/LyrebirdMacOSDemo/AppDelegate.swift b/Demos/LyrebirdMacOSDemo/LyrebirdMacOSDemo/AppDelegate.swift index b6b372a..62facf8 100644 --- a/Demos/LyrebirdMacOSDemo/LyrebirdMacOSDemo/AppDelegate.swift +++ b/Demos/LyrebirdMacOSDemo/LyrebirdMacOSDemo/AppDelegate.swift @@ -12,7 +12,7 @@ import LyrebirdUI // ── Demo selector ───────────────────────────────────────────────────────────── // Change `demo` to `.sineTone` or `.binDelay` to switch demos. private enum Demo { case vector, binDelay, sineTone } -private let demo: Demo = .binDelay +private let demo: Demo = .vector // ────────────────────────────────────────────────────────────────────────────── final class AppDelegate: NSObject, NSApplicationDelegate { diff --git a/Demos/LyrebirdMacOSDemo/LyrebirdMacOSDemo/main.swift b/Demos/LyrebirdMacOSDemo/LyrebirdMacOSDemo/main.swift index 9a4be6f..26124de 100644 --- a/Demos/LyrebirdMacOSDemo/LyrebirdMacOSDemo/main.swift +++ b/Demos/LyrebirdMacOSDemo/LyrebirdMacOSDemo/main.swift @@ -9,7 +9,7 @@ import LyrebirdSynth let engine = SynthesisEngine( blockSize: 512, - sampleRate: 48000, + sampleRate: 44100, numOutputChannels: 2, numInputChannels: 0, driver: CoreAudioDriver() diff --git a/Demos/LyrebirdNRTDemo/Package.swift b/Demos/LyrebirdNRTDemo/Package.swift index 8ea9550..418ca3d 100644 --- a/Demos/LyrebirdNRTDemo/Package.swift +++ b/Demos/LyrebirdNRTDemo/Package.swift @@ -17,7 +17,7 @@ let package = Package( .executableTarget( name: "LyrebirdNRTDemo", dependencies: [ - .product(name: "Lyrebird", package: "LyrebirdII"), + .product(name: "Lyrebird", package: "Lyrebird"), ], path: "LyrebirdNRTDemo" ), diff --git a/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo.xcodeproj/project.pbxproj b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo.xcodeproj/project.pbxproj new file mode 100644 index 0000000..993d3bf --- /dev/null +++ b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo.xcodeproj/project.pbxproj @@ -0,0 +1,328 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 60; + objects = { + +/* Begin PBXBuildFile section */ + E3C000000000000000000007 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3C000000000000000000006 /* main.swift */; }; + E3C000000000000000000013 /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = E3C000000000000000000012 /* Lyrebird */; }; + E3C000000000000000000015 /* SineTone.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3C000000000000000000014 /* SineTone.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + E3C000000000000000000004 /* LyrebirdQuickstartDemo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = LyrebirdQuickstartDemo; sourceTree = BUILT_PRODUCTS_DIR; }; + E3C000000000000000000006 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + E3C000000000000000000014 /* SineTone.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SineTone.swift; sourceTree = ""; }; + E3C000000000000000000017 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + E3C000000000000000000018 /* LyrebirdQuickstartDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LyrebirdQuickstartDemo.entitlements; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + E3C000000000000000000009 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E3C000000000000000000013 /* Lyrebird in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + E3C000000000000000000002 = { + isa = PBXGroup; + children = ( + E3C000000000000000000005 /* LyrebirdQuickstartDemo */, + E3C000000000000000000003 /* Products */, + ); + sourceTree = ""; + }; + E3C000000000000000000003 /* Products */ = { + isa = PBXGroup; + children = ( + E3C000000000000000000004 /* LyrebirdQuickstartDemo */, + ); + name = Products; + sourceTree = ""; + }; + E3C000000000000000000005 /* LyrebirdQuickstartDemo */ = { + isa = PBXGroup; + children = ( + E3C000000000000000000006 /* main.swift */, + E3C000000000000000000016 /* Synthesizers */, + E3C000000000000000000017 /* Info.plist */, + E3C000000000000000000018 /* LyrebirdQuickstartDemo.entitlements */, + ); + path = LyrebirdQuickstartDemo; + sourceTree = ""; + }; + E3C000000000000000000016 /* Synthesizers */ = { + isa = PBXGroup; + children = ( + E3C000000000000000000014 /* SineTone.swift */, + ); + path = Synthesizers; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + E3C00000000000000000000A /* LyrebirdQuickstartDemo */ = { + isa = PBXNativeTarget; + buildConfigurationList = E3C00000000000000000000B /* Build configuration list for PBXNativeTarget "LyrebirdQuickstartDemo" */; + buildPhases = ( + E3C000000000000000000008 /* Sources */, + E3C000000000000000000009 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = LyrebirdQuickstartDemo; + packageProductDependencies = ( + E3C000000000000000000012 /* Lyrebird */, + ); + productName = LyrebirdQuickstartDemo; + productReference = E3C000000000000000000004 /* LyrebirdQuickstartDemo */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + E3C000000000000000000001 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1600; + LastUpgradeCheck = 1600; + TargetAttributes = { + E3C00000000000000000000A = { + CreatedOnToolsVersion = 16.0; + }; + }; + }; + buildConfigurationList = E3C00000000000000000000E /* Build configuration list for PBXProject "LyrebirdQuickstartDemo" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = E3C000000000000000000002; + packageReferences = ( + E3C000000000000000000011 /* XCLocalSwiftPackageReference "../.." */, + ); + productRefGroup = E3C000000000000000000003 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + E3C00000000000000000000A /* LyrebirdQuickstartDemo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + E3C000000000000000000008 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E3C000000000000000000007 /* main.swift in Sources */, + E3C000000000000000000015 /* SineTone.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + E3C00000000000000000000C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = LyrebirdQuickstartDemo/LyrebirdQuickstartDemo.entitlements; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Manual; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_HARDENED_RUNTIME = YES; + INFOPLIST_FILE = LyrebirdQuickstartDemo/Info.plist; + MACOSX_DEPLOYMENT_TARGET = 15.0; + PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.LyrebirdQuickstartDemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 6.0; + }; + name = Debug; + }; + E3C00000000000000000000D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = LyrebirdQuickstartDemo/LyrebirdQuickstartDemo.entitlements; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Manual; + ENABLE_HARDENED_RUNTIME = YES; + INFOPLIST_FILE = LyrebirdQuickstartDemo/Info.plist; + MACOSX_DEPLOYMENT_TARGET = 15.0; + PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.LyrebirdQuickstartDemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 6.0; + }; + name = Release; + }; + E3C00000000000000000000F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + E3C000000000000000000010 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + E3C00000000000000000000B /* Build configuration list for PBXNativeTarget "LyrebirdQuickstartDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E3C00000000000000000000C /* Debug */, + E3C00000000000000000000D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + E3C00000000000000000000E /* Build configuration list for PBXProject "LyrebirdQuickstartDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E3C00000000000000000000F /* Debug */, + E3C000000000000000000010 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + E3C000000000000000000011 /* XCLocalSwiftPackageReference "../.." */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ../..; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + E3C000000000000000000012 /* Lyrebird */ = { + isa = XCSwiftPackageProductDependency; + package = E3C000000000000000000011 /* XCLocalSwiftPackageReference "../.." */; + productName = Lyrebird; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = E3C000000000000000000001 /* Project object */; +} diff --git a/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo.xcodeproj/xcshareddata/xcschemes/LyrebirdQuickstartDemo.xcscheme b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo.xcodeproj/xcshareddata/xcschemes/LyrebirdQuickstartDemo.xcscheme new file mode 100644 index 0000000..eeef690 --- /dev/null +++ b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo.xcodeproj/xcshareddata/xcschemes/LyrebirdQuickstartDemo.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/Info.plist b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/Info.plist new file mode 100644 index 0000000..a200af3 --- /dev/null +++ b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/Info.plist @@ -0,0 +1,14 @@ + + + + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleVersion + 1 + NSDesktopFolderUsageDescription + LyrebirdQuickstartDemo writes rendered audio files to the Desktop. + NSDocumentsFolderUsageDescription + LyrebirdQuickstartDemo writes rendered audio files to Documents. + + diff --git a/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo.entitlements b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo.entitlements new file mode 100644 index 0000000..80fbf9c --- /dev/null +++ b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.disable-library-validation + + + diff --git a/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/Synthesizers/SineTone.swift b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/Synthesizers/SineTone.swift new file mode 100644 index 0000000..4e99f06 --- /dev/null +++ b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/Synthesizers/SineTone.swift @@ -0,0 +1,21 @@ +// SineTone.swift +// Lyrebird +// +// Copyright (c) 2026 Joshua Parmenter / realizedsound +// SPDX-License-Identifier: MIT + +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). +// +// This is the same synth the `quickstart` CLI template scaffolds: +// lyrebird new MyFirstSound --template quickstart +final class SineTone: SynthesizerBase { + override func build() { + let sin: OscSin.Audio = OscSin.Audio(freq: 440.0, mul: 0.2) + let pan: Pan2 = Pan2(input: sin, pan: 0) + output(bus: 0, source: pan) + } +} diff --git a/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/main.swift b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/main.swift new file mode 100644 index 0000000..a6d17fa --- /dev/null +++ b/Demos/LyrebirdQuickstartDemo/LyrebirdQuickstartDemo/main.swift @@ -0,0 +1,44 @@ +// main.swift +// Lyrebird +// +// Copyright (c) 2026 Joshua Parmenter / realizedsound +// SPDX-License-Identifier: MIT + +// LyrebirdQuickstartDemo — the shortest path to sound. +// +// Mirrors the `quickstart` CLI template (`lyrebird new … --template quickstart`): +// the engine, a one-oscillator SineTone (see Synthesizers/SineTone.swift), and a +// main that starts it, plays a 440 Hz tone for 10 seconds, then stops and exits. + +import Foundation +import LyrebirdSynth + +// Seconds to play before exiting. +let quickstartDuration: Double = 5.0 + +do { + // The engine owns Core Audio and runs the graph on the RT thread. + let engine = SynthesisEngine( + blockSize: 512, + sampleRate: 48000, + numOutputChannels: 2, + numInputChannels: 0, + driver: CoreAudioDriver() + ) + + try engine.start() + let sineTone: SineTone = SineTone() + try engine.add(sineTone) // starts sounding immediately + + print("LyrebirdQuickstartDemo: playing a 440 Hz sine for \(Int(quickstartDuration)) seconds…") + Thread.sleep(forTimeInterval: quickstartDuration) + + engine.remove(sineTone) + + Thread.sleep(forTimeInterval: 0.1) + engine.stop() // closes the device + print("Done.") +} catch { + fputs("Lyrebird quickstart failed to start: \(error)\n", stderr) + exit(1) +} diff --git a/Demos/LyrebirdQuickstartDemo/Package.resolved b/Demos/LyrebirdQuickstartDemo/Package.resolved new file mode 100644 index 0000000..5c58234 --- /dev/null +++ b/Demos/LyrebirdQuickstartDemo/Package.resolved @@ -0,0 +1,24 @@ +{ + "originHash" : "293673d962d3211d0b8d90755b3dd158ce14df67eed9e956cb4457dba015dc09", + "pins" : [ + { + "identity" : "linenoise-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/andybest/linenoise-swift", + "state" : { + "revision" : "afc897c02b030af7333105c4fedcd843a8339238", + "version" : "0.0.3" + } + }, + { + "identity" : "nimble", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Quick/Nimble.git", + "state" : { + "revision" : "e9d769113660769a4d9dd3afb855562c0b7ae7b0", + "version" : "7.3.4" + } + } + ], + "version" : 3 +} diff --git a/Demos/LyrebirdQuickstartDemo/Package.swift b/Demos/LyrebirdQuickstartDemo/Package.swift new file mode 100644 index 0000000..239cd04 --- /dev/null +++ b/Demos/LyrebirdQuickstartDemo/Package.swift @@ -0,0 +1,25 @@ +// Package.swift +// Lyrebird +// +// Copyright (c) 2026 Joshua Parmenter / realizedsound +// SPDX-License-Identifier: MIT + +// swift-tools-version: 6.0 +import PackageDescription + +let package = Package( + name: "LyrebirdQuickstartDemo", + platforms: [.macOS(.v15)], + dependencies: [ + .package(path: "../.."), + ], + targets: [ + .executableTarget( + name: "LyrebirdQuickstartDemo", + dependencies: [ + .product(name: "Lyrebird", package: "Lyrebird"), + ], + path: "LyrebirdQuickstartDemo" + ), + ] +) diff --git a/Demos/LyrebirdScoreDemo/Package.swift b/Demos/LyrebirdScoreDemo/Package.swift index 0a7ac1b..69c47e3 100644 --- a/Demos/LyrebirdScoreDemo/Package.swift +++ b/Demos/LyrebirdScoreDemo/Package.swift @@ -17,7 +17,7 @@ let package = Package( .executableTarget( name: "LyrebirdScoreDemo", dependencies: [ - .product(name: "Lyrebird", package: "LyrebirdII"), + .product(name: "Lyrebird", package: "Lyrebird"), ], path: "LyrebirdScoreDemo" ), diff --git a/INSTALLATION_AND_USAGE.md b/INSTALLATION_AND_USAGE.md index 826c354..7da87c8 100644 --- a/INSTALLATION_AND_USAGE.md +++ b/INSTALLATION_AND_USAGE.md @@ -100,11 +100,21 @@ Full reference: [`docs/tooling/cli-guide.md`](docs/tooling/cli-guide.md). ## Generating projects +**First sound in 30 seconds** — the `quickstart` template is the shortest path from an installed CLI to audio: + +```bash +lyrebird new MyFirstSound --template quickstart +cd MyFirstSound && lyrebird run # plays a 440 Hz sine for 10 seconds, then exits +``` + +That's a complete, self-contained Swift Package: a one-oscillator `SineTone`, the engine, and a `main` that starts it, sleeps 10 seconds, and stops. Read it, then reach for the richer templates below. + `lyrebird new --template