Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e600f3a66 | |||
| 06bdcbbe92 | |||
| 162da89319 |
+1
-1
@@ -127,7 +127,7 @@ let package = Package(
|
||||
.library(name: "LyrebirdMyExtension", targets: ["LyrebirdMyExtension"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.0.0"),
|
||||
.package(url: "https://git.lyrebirdsynth.net/josh/Lyrebird", from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
// `makeDefaultAudioDriver()` selects the platform backend — Core Audio on Apple,
|
||||
// ALSA on Linux (needs libasound) — so the demo builds and runs on both.
|
||||
let engine = SynthesisEngine(
|
||||
blockSize: 512,
|
||||
sampleRate: 44100,
|
||||
numOutputChannels: 2,
|
||||
numInputChannels: 2,
|
||||
driver: CoreAudioDriver()
|
||||
driver: makeDefaultAudioDriver()
|
||||
)
|
||||
|
||||
do {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"originHash" : "c2996d6577ec0139a89be2f2d57d304047b7d5bf7f7eba2577fde9dc2fdc0b91",
|
||||
"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
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Package.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// swift-tools-version: 6.0
|
||||
import PackageDescription
|
||||
|
||||
// A single cross-platform GUI demo: one shared library of synths + views, and a
|
||||
// thin executable entry point that bootstraps the native toolkit per platform —
|
||||
// AppKit/SwiftUI on macOS, GTK4/SwiftOpenUI on Linux. The view bodies are written
|
||||
// to the subset of the View DSL that both backends share, so the UI is one source.
|
||||
//
|
||||
// macOS: swift run LyrebirdGUIDemo (or open the thin Xcode project)
|
||||
// Linux: swift run LyrebirdGUIDemo (needs libgtk-4-dev + libasound2-dev)
|
||||
//
|
||||
// Select the synth with LYREBIRD_DEMO=vector (default) or LYREBIRD_DEMO=sine.
|
||||
let package = Package(
|
||||
name: "LyrebirdGUIDemo",
|
||||
platforms: [.macOS(.v15)],
|
||||
products: [
|
||||
.library(name: "LyrebirdGUIDemoKit", targets: ["LyrebirdGUIDemoKit"]),
|
||||
.executable(name: "LyrebirdGUIDemo", targets: ["LyrebirdGUIDemo"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../.."),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "LyrebirdGUIDemoKit",
|
||||
dependencies: [
|
||||
.product(name: "Lyrebird", package: "Lyrebird"),
|
||||
.product(name: "LyrebirdUI", package: "Lyrebird"),
|
||||
],
|
||||
path: "Sources/LyrebirdGUIDemoKit"
|
||||
),
|
||||
.executableTarget(
|
||||
name: "LyrebirdGUIDemo",
|
||||
dependencies: [
|
||||
"LyrebirdGUIDemoKit",
|
||||
.product(name: "Lyrebird", package: "Lyrebird"),
|
||||
.product(name: "LyrebirdUI", package: "Lyrebird"),
|
||||
],
|
||||
path: "Sources/LyrebirdGUIDemo"
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,58 @@
|
||||
<!--
|
||||
README.md
|
||||
Lyrebird
|
||||
Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
SPDX-License-Identifier: MIT
|
||||
-->
|
||||
|
||||
# LyrebirdGUIDemo — one GUI demo, two platforms
|
||||
|
||||
A live-controllable synth GUI that builds and runs from a single source tree on
|
||||
**macOS** (AppKit + SwiftUI) and **Linux** (GTK4 + SwiftOpenUI). It is the
|
||||
cross-platform counterpart to the richer, macOS-only `LyrebirdMacOSDemo` Xcode
|
||||
project.
|
||||
|
||||
The split follows the "mostly in a package, thin entry points" shape:
|
||||
|
||||
| Piece | Where | Platform |
|
||||
|---|---|---|
|
||||
| Synths + views | `Sources/LyrebirdGUIDemoKit/` | shared — one source |
|
||||
| App bootstrap | `Sources/LyrebirdGUIDemo/main.swift` | one `#if` (AppKit vs GTK4) |
|
||||
|
||||
The view bodies are written to the subset of the View DSL that SwiftUI and
|
||||
SwiftOpenUI share, so there is **one** body per view — not a macOS copy and a
|
||||
Linux copy. Both back ends bind the same core `@UIParam` / `UIParamNode` model,
|
||||
so the controls, the oscilloscope, and the CPU meters are identical.
|
||||
|
||||
## Run it
|
||||
|
||||
```bash
|
||||
swift run LyrebirdGUIDemo # vector oscillator (default)
|
||||
LYREBIRD_DEMO=sine swift run LyrebirdGUIDemo # stereo sine tone
|
||||
```
|
||||
|
||||
- **macOS** — no extra setup; a native window opens with live audio via Core Audio.
|
||||
- **Linux** — needs `libgtk-4-dev` (GUI) and `libasound2-dev` + a sound device
|
||||
(audio). Without a sound backend the window still opens and the controls work;
|
||||
there is just no sound (`isLiveAudioAvailable` reports it, and the console says so).
|
||||
|
||||
## Open in an IDE
|
||||
|
||||
- **Xcode (macOS)** — open the folder (or `Package.swift`); Xcode treats it as a
|
||||
SwiftPM package. Pick the `LyrebirdGUIDemo` scheme and Run. No `.xcodeproj` to
|
||||
maintain — the package *is* the project.
|
||||
- **VS Code (Linux)** — open the folder with the Swift extension
|
||||
(`swiftlang.swift-vscode`); it picks up `Package.swift`. Run `LyrebirdGUIDemo`
|
||||
from the test/run explorer or a terminal.
|
||||
|
||||
## What each demo shows
|
||||
|
||||
- **vector** — `VectorOscillatorUI`: an XY pad crossfades four corner wavetables
|
||||
(sine / saw-ish / triangle / Hanning); frequency and amplitude knobs; a live
|
||||
oscilloscope and CPU-load strip.
|
||||
- **sine** — `SineToneUI`: a frequency slider, amplitude and pan knobs, a level
|
||||
readout, the scope and CPU strip, and a static envelope plot.
|
||||
|
||||
Add a synth by dropping a `SynthesizerBase` subclass and a node-based view into
|
||||
`LyrebirdGUIDemoKit`, then extend `DemoSelection` and the `demoContent()` switch
|
||||
in `main.swift`.
|
||||
@@ -0,0 +1,181 @@
|
||||
// main.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Thin cross-platform entry point. The shared synths + views live in
|
||||
// `LyrebirdGUIDemoKit`; this file only bootstraps the native toolkit and opens a
|
||||
// window hosting the selected demo view:
|
||||
//
|
||||
// • macOS — AppKit `NSApplication` + `LyrebirdWindow` (SwiftUI content).
|
||||
// • Linux — a GTK4 `App`/`WindowGroup` scene run by `GTK4Backend`.
|
||||
//
|
||||
// Run either with `swift run LyrebirdGUIDemo`. Pick the synth with
|
||||
// `LYREBIRD_DEMO=vector` (default) or `LYREBIRD_DEMO=sine`.
|
||||
//
|
||||
// `@ViewBuilder` and the window hosts come from SwiftUI on macOS and from
|
||||
// SwiftOpenUI (re-exported through `LyrebirdUI`) on Linux — hence the single
|
||||
// `#if canImport(SwiftUI)` import guard.
|
||||
#if canImport(SwiftUI)
|
||||
import SwiftUI
|
||||
#endif
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
import LyrebirdGUIDemoKit
|
||||
|
||||
// MARK: - Shared setup (runs on both platforms)
|
||||
|
||||
let selection: DemoSelection = DemoSelection.fromEnvironment()
|
||||
|
||||
private let demoBlockSize: Int = 512
|
||||
private let demoSampleRate: Double = 44_100.0
|
||||
private let demoScopeBufferSize: Int = 2048
|
||||
|
||||
// Oscilloscope tap on the stereo output buses. Must be set before `start()`.
|
||||
let demoScope: ScopeCapture = ScopeCapture(buses: [0, 1], bufferSize: demoScopeBufferSize)
|
||||
|
||||
// Core Audio on Apple, ALSA on a Linux build with libasound, else a silent
|
||||
// OfflineDriver. The GUI runs either way; `isLiveAudioAvailable` reports which.
|
||||
let demoDriver: any AudioDriver = makeDefaultAudioDriver()
|
||||
let demoEngine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: demoBlockSize,
|
||||
sampleRate: demoSampleRate,
|
||||
numOutputChannels: 2,
|
||||
numInputChannels: 0,
|
||||
driver: demoDriver
|
||||
)
|
||||
demoEngine.scopeTap = demoScope
|
||||
|
||||
// Both synths are cheap to build; only the selected one is added to the engine.
|
||||
// Building both keeps the node extraction below branch-free (no force-unwrap).
|
||||
let vectorSynth: VectorOscillatorUI = VectorOscillatorUI()
|
||||
let sineSynth: SineToneUI = SineToneUI()
|
||||
let activeSynth: SynthesizerBase = (selection == .vector) ? vectorSynth : sineSynth
|
||||
|
||||
// Extract the projected parameter nodes here, in main.swift's top-level
|
||||
// `@MainActor` context: `SynthesizerBase` is `@MainActor`, so `synth.$…` is only
|
||||
// reachable on the main actor. The nodes are not actor-isolated, so the
|
||||
// (nonisolated, on Linux) view body can read them freely.
|
||||
let vectorX: UIParamNode = vectorSynth.$x
|
||||
let vectorY: UIParamNode = vectorSynth.$y
|
||||
let vectorFreq: UIParamNode = vectorSynth.$frequency
|
||||
let vectorAmp: UIParamNode = vectorSynth.$amplitude
|
||||
|
||||
let sineFreq: UIParamNode = sineSynth.$frequency
|
||||
let sineAmp: UIParamNode = sineSynth.$amplitude
|
||||
let sinePan: UIParamNode = sineSynth.$pan
|
||||
|
||||
// A static example envelope for the sine demo's envelope plot.
|
||||
let demoEnvelope: Envelope = Envelope(
|
||||
levels: [0.0001, 1.0, 0.6, 0.4, 0.0001],
|
||||
durations: [0.05, 0.15, 0.4, 0.3],
|
||||
curves: [.exponential, .exponential, .lin, .exponential],
|
||||
loopNode: 2,
|
||||
releaseNode: 4
|
||||
)
|
||||
|
||||
// `SynthesisEngine` is not Sendable; the status view only reads plain CPU-load
|
||||
// doubles off it, and this demo runs entirely on the UI thread, so a nonisolated
|
||||
// handle is safe (mirrors the Linux UI demo).
|
||||
nonisolated(unsafe) let statusEngine: SynthesisEngine = demoEngine
|
||||
|
||||
/// Builds the view for the active selection. `if`/`else` maps to the DSL's
|
||||
/// `buildEither`, which both backends provide.
|
||||
///
|
||||
/// Isolation differs by backend: SwiftUI's `View` is `@MainActor`, so on macOS
|
||||
/// this must be `@MainActor` to construct the view (and it is called from
|
||||
/// AppKit's main-actor launch). SwiftOpenUI's `View` is nonisolated, so on Linux
|
||||
/// this stays nonisolated and is callable from the nonisolated scene closure.
|
||||
#if canImport(SwiftUI)
|
||||
@MainActor
|
||||
#endif
|
||||
@ViewBuilder
|
||||
func demoContent() -> some View {
|
||||
if selection == .vector {
|
||||
VectorOscillatorDemoView(
|
||||
xNode: vectorX,
|
||||
yNode: vectorY,
|
||||
frequencyNode: vectorFreq,
|
||||
amplitudeNode: vectorAmp,
|
||||
scope: demoScope,
|
||||
engine: statusEngine
|
||||
)
|
||||
} else {
|
||||
SineToneDemoView(
|
||||
frequencyNode: sineFreq,
|
||||
amplitudeNode: sineAmp,
|
||||
panNode: sinePan,
|
||||
scope: demoScope,
|
||||
engine: statusEngine,
|
||||
envelope: demoEnvelope
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Start the engine and add the selected synth. `engine.start()` / `add` are
|
||||
// @MainActor; main.swift's top level is main-actor isolated, so these are direct
|
||||
// calls. On a build with no live backend the GUI still runs (silently).
|
||||
do {
|
||||
try demoEngine.start()
|
||||
try demoEngine.add(activeSynth)
|
||||
} catch {
|
||||
print("[Lyrebird] demo engine setup failed: \(error)")
|
||||
}
|
||||
|
||||
if !isLiveAudioAvailable {
|
||||
print("[Lyrebird] no live audio backend — the controls still work, but there is no sound.")
|
||||
}
|
||||
|
||||
// MARK: - macOS front end (AppKit + SwiftUI)
|
||||
|
||||
#if os(macOS)
|
||||
import AppKit
|
||||
|
||||
final class DemoAppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
var window: LyrebirdWindow?
|
||||
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
let w: LyrebirdWindow = LyrebirdWindow(
|
||||
title: selection.windowTitle,
|
||||
width: 380,
|
||||
height: 620
|
||||
)
|
||||
w.open { demoContent() }
|
||||
window = w
|
||||
}
|
||||
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
true
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ notification: Notification) {
|
||||
demoEngine.stop()
|
||||
}
|
||||
}
|
||||
|
||||
MainActor.assumeIsolated {
|
||||
let app: NSApplication = NSApplication.shared
|
||||
app.setActivationPolicy(.regular)
|
||||
let delegate: DemoAppDelegate = DemoAppDelegate()
|
||||
app.delegate = delegate
|
||||
app.run()
|
||||
}
|
||||
|
||||
// MARK: - Linux front end (GTK4 + SwiftOpenUI)
|
||||
|
||||
#else
|
||||
|
||||
struct DemoApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup(selection.windowTitle) {
|
||||
demoContent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GTK4Backend().run(DemoApp.self)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
// DemoSelection.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Which synthesizer the demo runs, chosen by the `LYREBIRD_DEMO` environment
|
||||
/// variable. Both front ends (AppKit on macOS, GTK4 on Linux) read the same
|
||||
/// selection so one binary covers every patch.
|
||||
public enum DemoSelection: String, Sendable {
|
||||
|
||||
/// Vector oscillator with an XY blend pad (the default).
|
||||
case vector
|
||||
|
||||
/// Stereo sine tone with frequency / amplitude / pan controls.
|
||||
case sine
|
||||
|
||||
/// Resolve the selection from `LYREBIRD_DEMO` (defaults to `.vector`).
|
||||
public static func fromEnvironment() -> DemoSelection {
|
||||
let raw: String = ProcessInfo.processInfo.environment["LYREBIRD_DEMO"]?.lowercased() ?? "vector"
|
||||
return DemoSelection(rawValue: raw) ?? .vector
|
||||
}
|
||||
|
||||
/// Title-bar text for the window hosting this demo.
|
||||
public var windowTitle: String {
|
||||
switch self {
|
||||
case .vector: return "Lyrebird — Vector Oscillator"
|
||||
case .sine: return "Lyrebird — Sine Tone"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// SineToneDemoView.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if canImport(SwiftUI)
|
||||
import SwiftUI
|
||||
#endif
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Live controls for ``SineToneUI``: a frequency slider, amplitude and pan knobs,
|
||||
/// a level readout, a CPU-load strip, an oscilloscope, and a static envelope plot.
|
||||
///
|
||||
/// Node-based for the same reason as ``VectorOscillatorDemoView`` — the body must
|
||||
/// compile under both SwiftUI's `@MainActor` body and SwiftOpenUI's nonisolated one.
|
||||
public struct SineToneDemoView: View {
|
||||
|
||||
let frequencyNode: UIParamNode
|
||||
let amplitudeNode: UIParamNode
|
||||
let panNode: UIParamNode
|
||||
let scope: ScopeCapture
|
||||
let engine: SynthesisEngine
|
||||
let envelope: Envelope
|
||||
|
||||
public init(
|
||||
frequencyNode: UIParamNode,
|
||||
amplitudeNode: UIParamNode,
|
||||
panNode: UIParamNode,
|
||||
scope: ScopeCapture,
|
||||
engine: SynthesisEngine,
|
||||
envelope: Envelope
|
||||
) {
|
||||
self.frequencyNode = frequencyNode
|
||||
self.amplitudeNode = amplitudeNode
|
||||
self.panNode = panNode
|
||||
self.scope = scope
|
||||
self.engine = engine
|
||||
self.envelope = envelope
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
VStack {
|
||||
Text("Lyrebird — Sine Tone")
|
||||
.font(.headline)
|
||||
ParameterSlider("Frequency", node: frequencyNode, range: 440.0...880.0)
|
||||
HStack {
|
||||
ParameterKnob("Amplitude", node: amplitudeNode, range: 0.0...1.0)
|
||||
ParameterKnob("Pan", node: panNode, range: -1.0...1.0)
|
||||
ParameterLabel("Level", node: amplitudeNode, decimalPlaces: 2)
|
||||
}
|
||||
LyrebirdStatusView(engine: engine)
|
||||
LyrebirdScopeView(capture: scope)
|
||||
.frame(height: 120)
|
||||
LyrebirdEnvelopeView(envelope)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// SineToneUI.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// A stereo sine tone whose frequency, amplitude, and pan are live-controllable
|
||||
/// from the UI. The `@UIParam` slots are the same model both the SwiftUI (macOS)
|
||||
/// and SwiftOpenUI (Linux) controls bind to — one synthesizer, two front ends.
|
||||
public final class SineToneUI: SynthesizerBase {
|
||||
|
||||
/// Frequency in Hz. Slider range: 440–880 Hz.
|
||||
@UIParam public var frequency: Double = 440.0
|
||||
|
||||
/// Output amplitude (linear gain). Knob range: 0–1.
|
||||
@UIParam public var amplitude: Double = 0.25
|
||||
|
||||
/// Stereo pan position. Knob range: -1 (hard left) … 0 (center) … +1 (hard right).
|
||||
@UIParam public var pan: Double = 0.0
|
||||
|
||||
public override init() {
|
||||
super.init()
|
||||
}
|
||||
|
||||
public override func build() {
|
||||
let osc: OscSin.Audio = OscSin.Audio(freq: $frequency)
|
||||
output(bus: 0, source: Pan2(input: osc * $amplitude, pan: $pan))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// VectorOscillatorDemoView.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// One platform `#if` at the import site; identical body beneath. On macOS SwiftUI
|
||||
// supplies the View DSL; on Linux `LyrebirdUI` re-exports the SwiftOpenUI DSL, so
|
||||
// `VStack` / `Text` / `.padding()` resolve on both. The Lyrebird controls
|
||||
// (`ParameterXY`, `ParameterKnob`, …) and views live in `LyrebirdUI` on every
|
||||
// platform and bind the same core `UIParamNode`s this view is handed.
|
||||
#if canImport(SwiftUI)
|
||||
import SwiftUI
|
||||
#endif
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Live controls for ``VectorOscillatorUI``: an XY blend pad, frequency and
|
||||
/// amplitude knobs, a CPU-load strip, and an oscilloscope of the stereo output.
|
||||
///
|
||||
/// The view holds the projected `UIParamNode`s rather than the `@MainActor`
|
||||
/// synthesizer, because SwiftOpenUI's `body` is nonisolated (unlike SwiftUI's).
|
||||
/// The caller extracts the nodes on the main actor and hands them in; the nodes
|
||||
/// themselves are not actor-isolated, so a nonisolated body reads them freely.
|
||||
public struct VectorOscillatorDemoView: View {
|
||||
|
||||
let xNode: UIParamNode
|
||||
let yNode: UIParamNode
|
||||
let frequencyNode: UIParamNode
|
||||
let amplitudeNode: UIParamNode
|
||||
let scope: ScopeCapture
|
||||
let engine: SynthesisEngine
|
||||
|
||||
public init(
|
||||
xNode: UIParamNode,
|
||||
yNode: UIParamNode,
|
||||
frequencyNode: UIParamNode,
|
||||
amplitudeNode: UIParamNode,
|
||||
scope: ScopeCapture,
|
||||
engine: SynthesisEngine
|
||||
) {
|
||||
self.xNode = xNode
|
||||
self.yNode = yNode
|
||||
self.frequencyNode = frequencyNode
|
||||
self.amplitudeNode = amplitudeNode
|
||||
self.scope = scope
|
||||
self.engine = engine
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
VStack {
|
||||
Text("Lyrebird — Vector Oscillator")
|
||||
.font(.headline)
|
||||
ParameterXY(
|
||||
xLabel: "X (A↔B)", xNode: xNode, xRange: 0.0...1.0,
|
||||
yLabel: "Y (AB↔CD)", yNode: yNode, yRange: 0.0...1.0
|
||||
)
|
||||
.frame(width: 240, height: 240)
|
||||
HStack {
|
||||
ParameterKnob("Frequency", node: frequencyNode, range: 40.0...2000.0)
|
||||
ParameterKnob("Amplitude", node: amplitudeNode, range: 0.0...1.0)
|
||||
ParameterLabel("Freq (Hz)", node: frequencyNode, decimalPlaces: 1)
|
||||
}
|
||||
LyrebirdStatusView(engine: engine)
|
||||
LyrebirdScopeView(capture: scope)
|
||||
.frame(height: 120)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
// VectorOscillatorUI.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// A stereo vector oscillator whose XY position, frequency, and amplitude are
|
||||
/// live-controllable from the UI.
|
||||
///
|
||||
/// Four corner wavetables are crossfaded on a 2D XY plane:
|
||||
///
|
||||
/// C (triangle) ── D (Hanning) (y = 1)
|
||||
/// │ │
|
||||
/// A (sine) ──── B (saw-ish) (y = 0)
|
||||
/// x=0 x=1
|
||||
///
|
||||
/// Moving X blends A↔B (and C↔D); moving Y blends the AB mix into the CD mix.
|
||||
public final class VectorOscillatorUI: SynthesizerBase {
|
||||
|
||||
/// X-axis blend position. 0 = corner A/C, 1 = corner B/D. Normalized [0, 1].
|
||||
@UIParam public var x: Double = 0.5
|
||||
|
||||
/// Y-axis blend position. 0 = bottom (A, B), 1 = top (C, D). Normalized [0, 1].
|
||||
@UIParam public var y: Double = 0.5
|
||||
|
||||
/// Oscillator frequency in Hz. Slider range: 40–2000 Hz.
|
||||
@UIParam public var frequency: Double = 220.0
|
||||
|
||||
/// Output amplitude (linear gain). Knob range: 0–1.
|
||||
@UIParam public var amplitude: Double = 0.25
|
||||
|
||||
private let bufferA: LyrebirdBuffer // corner A: sine
|
||||
private let bufferB: LyrebirdBuffer // corner B: 16-partial saw-ish
|
||||
private let bufferC: LyrebirdBuffer // corner C: triangle
|
||||
private let bufferD: LyrebirdBuffer // corner D: Hanning window shape
|
||||
|
||||
public override init() {
|
||||
let tableSize: Int = lyrebirdDefaultTableSize
|
||||
|
||||
let a: LyrebirdBuffer = LyrebirdBuffer(count: tableSize)
|
||||
a.fillSine()
|
||||
|
||||
let b: LyrebirdBuffer = LyrebirdBuffer(count: tableSize)
|
||||
b.fill(partials: 16)
|
||||
|
||||
let c: LyrebirdBuffer = LyrebirdBuffer(count: tableSize)
|
||||
c.fillTriangle()
|
||||
|
||||
let d: LyrebirdBuffer = LyrebirdBuffer(count: tableSize)
|
||||
d.fillHanning()
|
||||
|
||||
self.bufferA = a
|
||||
self.bufferB = b
|
||||
self.bufferC = c
|
||||
self.bufferD = d
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
public override func build() {
|
||||
let osc: VectorOscillator.Audio = VectorOscillator.Audio(
|
||||
bufferA: bufferA,
|
||||
bufferB: bufferB,
|
||||
bufferC: bufferC,
|
||||
bufferD: bufferD,
|
||||
freq: $frequency,
|
||||
x: $x,
|
||||
y: $y,
|
||||
mul: $amplitude
|
||||
)
|
||||
output(bus: 0, source: Pan2(input: osc, pan: 0.0))
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,21 @@
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
// Output to the Desktop — triggers the NSDesktopFolderUsageDescription TCC prompt on first run.
|
||||
let outputURL = FileManager.default.homeDirectoryForCurrentUser
|
||||
// Offline render has no audio device, so this demo runs the same on macOS and Linux.
|
||||
// Only the output container differs: CAF is Apple-only (it goes through `ExtAudioFile`),
|
||||
// so off Apple we write the portable WAV codec instead.
|
||||
#if canImport(AudioToolbox)
|
||||
// Apple: CAF on the Desktop — triggers the NSDesktopFolderUsageDescription TCC prompt on first run.
|
||||
let outputURL: URL = FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent("Desktop/nrt_output.caf")
|
||||
let outputFormat: AudioFileFormat = .cafFloat32
|
||||
#else
|
||||
// Linux (and any non-Apple): WAV in the current working directory — no special-folder
|
||||
// permission needed, and `WavFileWriter` is the portable encoder off Apple.
|
||||
let outputURL: URL = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
|
||||
.appendingPathComponent("nrt_output.wav")
|
||||
let outputFormat: AudioFileFormat = .wavFloat32
|
||||
#endif
|
||||
|
||||
// Render parameters.
|
||||
let sampleRate: Double = 48000
|
||||
@@ -43,7 +55,7 @@ let tailDuration: Double = 0.1
|
||||
let lastStart = voices.map(\.start).max() ?? 0.0
|
||||
let totalDur = lastStart + interSetDelay + voiceLength + tailDuration
|
||||
|
||||
let driver = NRTDriver(outputURL: outputURL, duration: totalDur)
|
||||
let driver = NRTDriver(outputURL: outputURL, duration: totalDur, format: outputFormat)
|
||||
let engine = SynthesisEngine(
|
||||
blockSize: blockSize,
|
||||
sampleRate: sampleRate,
|
||||
@@ -77,7 +89,7 @@ do {
|
||||
)
|
||||
}
|
||||
} catch {
|
||||
fputs("engine.schedule failed: \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("engine.schedule failed: \(error)\n".utf8))
|
||||
exit(1)
|
||||
}
|
||||
|
||||
@@ -87,7 +99,7 @@ do {
|
||||
try engine.start()
|
||||
print("Done.")
|
||||
} catch {
|
||||
fputs("Render failed: \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("Render failed: \(error)\n".utf8))
|
||||
exit(1)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,15 @@ import LyrebirdSynth
|
||||
let quickstartDuration: Double = 5.0
|
||||
|
||||
do {
|
||||
// The engine owns Core Audio and runs the graph on the RT thread.
|
||||
// The engine owns the audio device and runs the graph on the RT thread.
|
||||
// `makeDefaultAudioDriver()` picks the platform backend — Core Audio on Apple,
|
||||
// ALSA on Linux (needs libasound) — so this demo builds and runs on both.
|
||||
let engine = SynthesisEngine(
|
||||
blockSize: 512,
|
||||
sampleRate: 48000,
|
||||
numOutputChannels: 2,
|
||||
numInputChannels: 0,
|
||||
driver: CoreAudioDriver()
|
||||
driver: makeDefaultAudioDriver()
|
||||
)
|
||||
|
||||
try engine.start()
|
||||
@@ -39,6 +41,6 @@ do {
|
||||
engine.stop() // closes the device
|
||||
print("Done.")
|
||||
} catch {
|
||||
fputs("Lyrebird quickstart failed to start: \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("Lyrebird quickstart failed to start: \(error)\n".utf8))
|
||||
exit(1)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,17 @@
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
/// Directory this demo writes its output files to: the Desktop on Apple (matching the
|
||||
/// Xcode scheme), the current working directory elsewhere (Linux has no Desktop folder
|
||||
/// to grant, and `swift run` starts from a known location).
|
||||
func demoOutputDirectory() -> URL {
|
||||
#if canImport(AudioToolbox)
|
||||
return FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent("Desktop")
|
||||
#else
|
||||
return URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Builds a multi-part Score using every DSL node type, exports MusicXML, round-trips
|
||||
/// the document, and reports render statistics.
|
||||
///
|
||||
@@ -58,15 +69,15 @@ final class ScoreDemo: DemoProtocol {
|
||||
/// Export MusicXML and print the round-trip event count. Does not interact with
|
||||
/// the engine or schedule any voices.
|
||||
func runDemo() {
|
||||
// Step 1 — write MusicXML to Desktop.
|
||||
let xmlURL: URL = FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent("Desktop/LyrebirdScoreDemo.musicxml")
|
||||
// Step 1 — write MusicXML to the demo output directory.
|
||||
let xmlURL: URL = demoOutputDirectory()
|
||||
.appendingPathComponent("LyrebirdScoreDemo.musicxml")
|
||||
let xmlString: String = score.toMusicXMLString()
|
||||
do {
|
||||
try xmlString.write(to: xmlURL, atomically: true, encoding: .utf8)
|
||||
print("MusicXML written → \(xmlURL.path)")
|
||||
} catch {
|
||||
fputs("Failed to write MusicXML: \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("Failed to write MusicXML: \(error)\n".utf8))
|
||||
}
|
||||
|
||||
// Step 2 — round-trip sanity check.
|
||||
@@ -105,7 +116,7 @@ final class ScoreDemo: DemoProtocol {
|
||||
print("Score key (G major): \(rt.keySignature == .gMajor ? "OK" : "MISMATCH(\(rt.keySignature))")")
|
||||
}
|
||||
} catch {
|
||||
fputs("MusicXML round-trip failed: \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("MusicXML round-trip failed: \(error)\n".utf8))
|
||||
}
|
||||
|
||||
// Step 2b — sectioned showcase: multiple Sections assembled into one
|
||||
@@ -119,8 +130,8 @@ final class ScoreDemo: DemoProtocol {
|
||||
// `rehearsalMarksAsStaffText: true` option emits boxed <words> staff text
|
||||
// instead, but that attaches to a staff and can collide with notation.
|
||||
let showcase: Score = ScoreDemo.makeSectionedShowcase()
|
||||
let showcaseURL: URL = FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent("Desktop/LyrebirdScoreSections.musicxml")
|
||||
let showcaseURL: URL = demoOutputDirectory()
|
||||
.appendingPathComponent("LyrebirdScoreSections.musicxml")
|
||||
do {
|
||||
try showcase.toMusicXMLString().write(to: showcaseURL, atomically: true, encoding: .utf8)
|
||||
print("Sectioned showcase written → \(showcaseURL.path)")
|
||||
@@ -132,7 +143,7 @@ final class ScoreDemo: DemoProtocol {
|
||||
print("Sections → rehearsal marks: \(markList)")
|
||||
print("Sectioned showcase parts: \(showcase.parts.map { $0.name }.joined(separator: ", "))")
|
||||
} catch {
|
||||
fputs("Failed to write sectioned showcase: \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("Failed to write sectioned showcase: \(error)\n".utf8))
|
||||
}
|
||||
|
||||
// Step 3 — report render parameters.
|
||||
@@ -185,7 +196,7 @@ final class ScoreDemo: DemoProtocol {
|
||||
try engine.schedule(voice, after: startSeconds)
|
||||
scheduledCount += 1
|
||||
} catch {
|
||||
fputs("engine.schedule failed for beat \(event.beat): \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("engine.schedule failed for beat \(event.beat): \(error)\n".utf8))
|
||||
failedCount += 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,16 @@
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
// Output paths — both land on the Desktop.
|
||||
let cafURL: URL = FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent("Desktop/LyrebirdScoreDemo.caf")
|
||||
// Audio output. CAF is Apple-only (ExtAudioFile), so off Apple we render the
|
||||
// portable WAV codec; `demoOutputDirectory()` is the Desktop on Apple and the
|
||||
// current working directory elsewhere (see ScoreDemo.swift).
|
||||
#if canImport(AudioToolbox)
|
||||
let outputFormat: AudioFileFormat = .cafFloat32
|
||||
let audioURL: URL = demoOutputDirectory().appendingPathComponent("LyrebirdScoreDemo.caf")
|
||||
#else
|
||||
let outputFormat: AudioFileFormat = .wavFloat32
|
||||
let audioURL: URL = demoOutputDirectory().appendingPathComponent("LyrebirdScoreDemo.wav")
|
||||
#endif
|
||||
|
||||
// Render parameters.
|
||||
let sampleRate: Double = 48000
|
||||
@@ -23,7 +30,7 @@ let totalDuration: Double = demo.totalDuration
|
||||
demo.runDemo()
|
||||
|
||||
// Create NRTDriver and engine.
|
||||
let driver: NRTDriver = NRTDriver(outputURL: cafURL, duration: totalDuration)
|
||||
let driver: NRTDriver = NRTDriver(outputURL: audioURL, duration: totalDuration, format: outputFormat)
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: blockSize,
|
||||
sampleRate: sampleRate,
|
||||
@@ -37,12 +44,12 @@ let engine: SynthesisEngine = SynthesisEngine(
|
||||
// isolated, so this is a plain direct call — no MainActor hop needed.
|
||||
demo.scheduleVoices(engine: engine)
|
||||
|
||||
print(String(format: "Rendering %.2f s → %@", totalDuration, cafURL.path))
|
||||
print(String(format: "Rendering %.2f s → %@", totalDuration, audioURL.path))
|
||||
|
||||
do {
|
||||
try engine.start()
|
||||
print("Done.")
|
||||
} catch {
|
||||
fputs("Render failed: \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("Render failed: \(error)\n".utf8))
|
||||
exit(1)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
How to add Lyrebird to a project and scaffold the five kinds of app it supports: real-time, real-time + UI, non-real-time (offline) render, AUv3 plugin, and iOS.
|
||||
|
||||
The package is hosted at <https://realizedsound.mooo.com/josh/Lyrebird>.
|
||||
The package is hosted at <https://git.lyrebirdsynth.net/josh/Lyrebird>.
|
||||
|
||||
---
|
||||
|
||||
@@ -29,7 +29,7 @@ let package = Package(
|
||||
name: "MyPiece",
|
||||
platforms: [.macOS(.v15), .iOS(.v18)],
|
||||
dependencies: [
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.0.0"),
|
||||
.package(url: "https://git.lyrebirdsynth.net/josh/Lyrebird", from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
|
||||
+3
@@ -10,6 +10,9 @@
|
||||
<FileRef
|
||||
location = "group:Demos/LyrebirdMacOSDemo/LyrebirdMacOSDemo.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Demos/LyrebirdGUIDemo">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Demos/LyrebirdiOSDemo/LyrebirdiOSDemo.xcodeproj">
|
||||
</FileRef>
|
||||
|
||||
@@ -6,6 +6,25 @@ Informed by 20+ years of SuperCollider practice, adapted to Swift idioms and a s
|
||||
|
||||
---
|
||||
|
||||
## Try it — run a demo
|
||||
|
||||
The fastest way in is a demo project, not a snippet to copy. Each demo under [`Demos/`](Demos/) is a standalone SwiftPM package that depends on this checkout, so `swift run` from its folder builds and runs it — on **macOS** (Xcode optional) and **Linux** (VS Code optional), no project file to open:
|
||||
|
||||
```bash
|
||||
git clone https://git.lyrebirdsynth.net/josh/Lyrebird.git
|
||||
cd Lyrebird
|
||||
|
||||
(cd Demos/LyrebirdQuickstartDemo && swift run) # a 440 Hz sine — the shortest path to sound
|
||||
(cd Demos/LyrebirdNRTDemo && swift run) # offline render → an audio file, no sound device needed
|
||||
(cd Demos/LyrebirdDemo && swift run) # a fuller reverb smoke-test through your default output
|
||||
```
|
||||
|
||||
These three run the same on macOS and Linux. Each has a `Synthesizers/` folder — drop a `SynthesizerBase` subclass in, re-run, and you are building your own voice. The GUI demos (SwiftUI on macOS/iOS; the GTK4 UI on Linux) and the full list are under [Demo projects](#demo-projects).
|
||||
|
||||
On Linux the live-audio demos need `libasound2-dev`; the offline NRT demo needs nothing. Full Linux setup is in the [On Linux](#on-linux--vs-code-or-any-editor-no-xcode) notes and [`docs/linux-getting-started.md`](docs/linux-getting-started.md).
|
||||
|
||||
---
|
||||
|
||||
## A quick taste
|
||||
|
||||
Three layers, each usable on its own: **Generators** are the unit signal graph, **Synthesizers** package a graph plus live parameters into a playable voice, and the **Engine** drives the platform audio backend (Core Audio on Apple, ALSA on Linux) and schedules voices sample-accurately.
|
||||
@@ -145,7 +164,7 @@ The REPL is text-only and works from any project that depends on Lyrebird; the s
|
||||
Add the package:
|
||||
|
||||
```
|
||||
https://realizedsound.mooo.com/josh/Lyrebird.git
|
||||
https://git.lyrebirdsynth.net/josh/Lyrebird.git
|
||||
```
|
||||
|
||||
**File ▸ Add Package Dependencies…** → that URL → **Up to Next Major** from `1.0.0` → add the `Lyrebird` product (and `LyrebirdUI` for the SwiftUI controls). Write `import LyrebirdSynth` in your code (the product is `Lyrebird`; the module it vends is `LyrebirdSynth`).
|
||||
@@ -158,7 +177,7 @@ Full walk-through (SPM manifest form, local-path dev dependency, per-template de
|
||||
|
||||
```swift
|
||||
dependencies: [
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.0.0"),
|
||||
.package(url: "https://git.lyrebirdsynth.net/josh/Lyrebird", from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
@@ -187,18 +206,19 @@ xed . # opens Package.swift — Xcode auto-generates schemes for every target
|
||||
|
||||
### Schemes
|
||||
|
||||
Workspace scheme selector exposes ten entries:
|
||||
Workspace scheme selector exposes eleven entries:
|
||||
|
||||
| Scheme | Purpose | Platform |
|
||||
|---|---|---|
|
||||
| `Lyrebird-Package` | Umbrella — builds Lyrebird + LyrebirdUI + LyrebirdLiveCompile + LyrebirdC + LyrebirdBenchmark + LyrebirdCLI, runs the test suites, launches/profiles `LyrebirdCLI` | macOS |
|
||||
| `LyrebirdQuickstartDemo` | CLI — fastest sound: a one-oscillator `SineTone` that plays 440 Hz for 10 s and exits | macOS |
|
||||
| `LyrebirdQuickstartDemo` | CLI — fastest sound: a one-oscillator `SineTone` that plays 440 Hz for 10 s and exits | macOS · Linux |
|
||||
| `LyrebirdUI` | Builds the `LyrebirdUI` module only (SwiftUI parameter controls + visualisations) | macOS |
|
||||
| `LyrebirdDemo` | CLI — plays through default output via `CoreAudioDriver` | macOS |
|
||||
| `LyrebirdDemo` | CLI — plays through default output via `makeDefaultAudioDriver()` | macOS · Linux |
|
||||
| `LyrebirdMacOSDemo` | SwiftUI app — live oscilloscope, `@UIParam` knobs | macOS |
|
||||
| `LyrebirdGUIDemo` | Cross-platform GUI — one shared source; SwiftUI here, GTK4 on Linux (`LYREBIRD_DEMO=vector`/`sine`) | macOS · Linux |
|
||||
| `LyrebirdiOSDemo` | SwiftUI app — same UI via `iOSAudioDriver` (RemoteIO) | iOS |
|
||||
| `LyrebirdNRTDemo` | CLI — offline render to CAF via `NRTDriver` | macOS |
|
||||
| `LyrebirdScoreDemo` | CLI — builds notated `Score`s (result-builder DSL), exports MusicXML, renders to CAF via `NRTDriver` | macOS |
|
||||
| `LyrebirdNRTDemo` | CLI — offline render via `NRTDriver` (CAF on macOS, WAV on Linux) | macOS · Linux |
|
||||
| `LyrebirdScoreDemo` | CLI — builds notated `Score`s (result-builder DSL), exports MusicXML, renders via `NRTDriver` (CAF on macOS, WAV on Linux) | macOS · Linux |
|
||||
| `LyrebirdAUv3Demo` | AUv3 host app + `aumu` plugin extension (`Realized Sound: LyrebirdFM`) — a two-operator FM synth wrapped as `LyrebirdAudioUnit`, loadable in Logic, GarageBand, AUM, Loopy Pro, etc. Run the host app once to register the extension. | macOS |
|
||||
| `LyrebirdScratch` | Live-coding scratchpad — type Swift snippets, ⌘↩ compiles and runs against the engine, ⌘⇧↩ additive | macOS |
|
||||
|
||||
@@ -231,7 +251,17 @@ swift run LyrebirdCLI repl # the CLI (also `new`
|
||||
LYREBIRD_ENABLE_LINUX_UI=1 swift run LyrebirdUILinuxDemo # the GTK4 UI demo
|
||||
```
|
||||
|
||||
The SwiftUI / AUv3 / iOS demos in the scheme table do not build on Linux. Full walk-through — toolchain, VS Code, building, running a sample: [`docs/linux-getting-started.md`](docs/linux-getting-started.md).
|
||||
The CLI demo projects build and run on Linux too — each is its own package, so run it from its folder (`swift run` picks up the single executable):
|
||||
|
||||
```bash
|
||||
(cd Demos/LyrebirdNRTDemo && swift run) # offline render → ./nrt_output.wav (no audio device needed)
|
||||
(cd Demos/LyrebirdQuickstartDemo && swift run) # a 440 Hz sine (needs libasound + a sound device)
|
||||
(cd Demos/LyrebirdDemo && swift run) # reverb smoke-test through default output
|
||||
(cd Demos/LyrebirdScoreDemo && swift run) # notated Score → MusicXML + a rendered WAV (no device)
|
||||
(cd Demos/LyrebirdGUIDemo && swift run) # cross-platform GUI via GTK4 (needs libgtk-4-dev); LYREBIRD_DEMO=vector|sine
|
||||
```
|
||||
|
||||
The four CLI demos plus `LyrebirdGUIDemo` (a GTK4 window here, SwiftUI on macOS) run on Linux; the AUv3 / iOS / `LyrebirdMacOSDemo` GUI demos are Apple-only. Full walk-through — toolchain, VS Code, building, running a sample: [`docs/linux-getting-started.md`](docs/linux-getting-started.md).
|
||||
|
||||
---
|
||||
|
||||
@@ -243,23 +273,24 @@ swift test # run all 5481 tests
|
||||
swift test --filter LyrebirdTests # run one suite
|
||||
swift run lyrebird # run the CLI
|
||||
swift run lyrebird repl # Swift REPL with Lyrebird available
|
||||
swift run LyrebirdDemo # run the hardware smoke-test demo
|
||||
(cd Demos/LyrebirdDemo && swift run) # run a demo project (each Demos/* is its own package)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Demo projects
|
||||
|
||||
All eight live in [`Demos/`](Demos/). Open via `Lyrebird.xcworkspace`.
|
||||
All nine live in [`Demos/`](Demos/). Each is its own SwiftPM package depending on the local checkout, so a demo runs with `swift run` from its folder on **any** platform it supports — no Xcode needed. On macOS you can also open them together via `Lyrebird.xcworkspace`. The demos marked **Linux** build and run on Linux as well (see the Linux VS Code section above); `LyrebirdGUIDemo` is the cross-platform GUI — SwiftUI on macOS, GTK4 on Linux, one source.
|
||||
|
||||
| Demo | What it does | Platform |
|
||||
|---|---|---|
|
||||
| [`LyrebirdQuickstartDemo`](Demos/LyrebirdQuickstartDemo/) | CLI — fastest sound: a one-oscillator `SineTone` plays 440 Hz for 10 s, then exits (mirrors the `quickstart` template) | macOS |
|
||||
| [`LyrebirdDemo`](Demos/LyrebirdDemo/) | CLI — plays through default output via `CoreAudioDriver` | macOS |
|
||||
| [`LyrebirdMacOSDemo`](Demos/LyrebirdMacOSDemo/) | SwiftUI app — live oscilloscope, `@UIParam` knobs | macOS |
|
||||
| [`LyrebirdQuickstartDemo`](Demos/LyrebirdQuickstartDemo/) | CLI — fastest sound: a one-oscillator `SineTone` plays 440 Hz for 10 s, then exits (mirrors the `quickstart` template) | macOS · Linux |
|
||||
| [`LyrebirdDemo`](Demos/LyrebirdDemo/) | CLI — plays through default output via `makeDefaultAudioDriver()` (Core Audio on macOS, ALSA on Linux) | macOS · Linux |
|
||||
| [`LyrebirdGUIDemo`](Demos/LyrebirdGUIDemo/) | GUI — live `@UIParam` controls, XY pad, oscilloscope, CPU meters, from one shared source; AppKit/SwiftUI on macOS, GTK4/SwiftOpenUI on Linux (`LYREBIRD_DEMO=vector`/`sine`) | macOS · Linux |
|
||||
| [`LyrebirdMacOSDemo`](Demos/LyrebirdMacOSDemo/) | SwiftUI app — live oscilloscope, `@UIParam` knobs, vector / sine / spectral-bin-delay patches | macOS |
|
||||
| [`LyrebirdiOSDemo`](Demos/LyrebirdiOSDemo/) | SwiftUI app — same UI system via `iOSAudioDriver` (RemoteIO) | iOS |
|
||||
| [`LyrebirdNRTDemo`](Demos/LyrebirdNRTDemo/) | CLI — offline render to CAF file via `NRTDriver` | macOS |
|
||||
| [`LyrebirdScoreDemo`](Demos/LyrebirdScoreDemo/) | CLI — notated `Score` → MusicXML export + offline render to CAF via `NRTDriver` | macOS |
|
||||
| [`LyrebirdNRTDemo`](Demos/LyrebirdNRTDemo/) | CLI — offline render via `NRTDriver` (CAF on macOS, WAV on Linux) | macOS · Linux |
|
||||
| [`LyrebirdScoreDemo`](Demos/LyrebirdScoreDemo/) | CLI — notated `Score` → MusicXML export + offline render via `NRTDriver` (CAF on macOS, WAV on Linux) | macOS · Linux |
|
||||
| [`LyrebirdAUv3Demo`](Demos/LyrebirdAUv3Demo/) | AUv3 host app + `aumu` plugin extension (`Realized Sound: LyrebirdFM`) — a two-operator FM synth wrapped as `LyrebirdAudioUnit`, loadable in Logic, GarageBand, AUM, Loopy Pro | macOS |
|
||||
| [`LyrebirdScratch`](Demos/LyrebirdScratch/) | Live-coding scratchpad — type Swift, ⌘↩ compiles and runs against the engine, ⌘⇧↩ additive | macOS |
|
||||
|
||||
@@ -297,14 +328,10 @@ Arrow-key editing, tab completion, persistent history (`~/.lyrebird_history`). `
|
||||
|
||||
Lyrebird supports out-of-tree Swift packages that add `Generator` or `Synthesizer` implementations. Extension packages depend on Lyrebird via SwiftPM, host their own source, and ship their own version releases — core users pin the version range they want.
|
||||
|
||||
| Package | Description |
|
||||
|---|---|
|
||||
| [`LyrebirdATK`](#) | First-order Ambisonics toolkit (37 `Foa*` UGens, MIT KEMAR HRIR set, binaural decoder). Worked example for the Extension SDK. |
|
||||
|
||||
Building your own extension package:
|
||||
|
||||
- **API contract**: [`docs/protocols/extension-sdk.md`](docs/protocols/extension-sdk.md) — tier-1 stable public surface + tier-2 `@_spi(LyrebirdExtensions)` symbols and versioning policy.
|
||||
- **Walk-through**: [`docs/extension-authors-guide.md`](docs/extension-authors-guide.md) — end-to-end build a new extension package using LyrebirdATK as the reference.
|
||||
- **Walk-through**: [`docs/extension-authors-guide.md`](docs/extension-authors-guide.md) — end-to-end build a new extension package.
|
||||
|
||||
---
|
||||
|
||||
@@ -322,6 +349,7 @@ LyrebirdII/
|
||||
├── Demos/
|
||||
│ ├── LyrebirdQuickstartDemo/ # fastest sound — SineTone plays 10 s then exits
|
||||
│ ├── LyrebirdDemo/ # (same as Sources/LyrebirdDemo — workspace target)
|
||||
│ ├── LyrebirdGUIDemo/ # cross-platform GUI — SwiftUI (macOS) + GTK4 (Linux), one source
|
||||
│ ├── LyrebirdMacOSDemo/ # macOS SwiftUI app
|
||||
│ ├── LyrebirdiOSDemo/ # iOS SwiftUI app
|
||||
│ ├── LyrebirdNRTDemo/ # offline renderer
|
||||
|
||||
@@ -164,7 +164,7 @@ Generated `Package.swift` uses `.package(name: "Lyrebird", path: ...)`; the `.xc
|
||||
The generated `Package.swift` depends on the Lyrebird Bitbucket repository:
|
||||
|
||||
```swift
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.0.0"),
|
||||
.package(url: "https://git.lyrebirdsynth.net/josh/Lyrebird", from: "1.0.0"),
|
||||
```
|
||||
|
||||
If you want to work against a local checkout instead, swap to a path dependency:
|
||||
@@ -201,7 +201,7 @@ single step — no special build settings required.
|
||||
**File ▸ Add Package Dependencies…**, enter the repository URL:
|
||||
|
||||
```
|
||||
https://realizedsound.mooo.com/josh/Lyrebird.git
|
||||
https://git.lyrebirdsynth.net/josh/Lyrebird.git
|
||||
```
|
||||
|
||||
Choose **Up to Next Major Version** from `1.0.0`, then add the `Lyrebird`
|
||||
|
||||
@@ -12,7 +12,7 @@ extension ProjectScaffolder {
|
||||
|
||||
/// SPM URL Lyrebird is resolved from. Single source of truth for both
|
||||
/// the generated `Package.swift` manifest and every embedded `.xcodeproj`.
|
||||
public static let lyrebirdPackageURL: String = "https://realizedsound.mooo.com/josh/Lyrebird"
|
||||
public static let lyrebirdPackageURL: String = "https://git.lyrebirdsynth.net/josh/Lyrebird"
|
||||
|
||||
/// Lower bound on the Lyrebird version range — `upToNextMajorVersion`.
|
||||
public static let lyrebirdMinimumVersion: String = "1.0.0"
|
||||
|
||||
@@ -41,9 +41,11 @@ EXCLUSIONS=(
|
||||
)
|
||||
|
||||
# Regex the release repo's origin URL must match — a guard so --apply can never
|
||||
# nuke the wrong directory. Requires the mooo host AND the `Lyrebird` repo path
|
||||
# (so a sibling mooo repo like ShoeGaze can't be mistaken for the release repo).
|
||||
RELEASE_REMOTE_REGEX='realizedsound\.mooo\.com.*/Lyrebird(\.git)?/?$'
|
||||
# nuke the wrong directory. Requires the gitea host AND the `Lyrebird` repo path
|
||||
# (so a sibling repo like ShoeGaze can't be mistaken for the release repo).
|
||||
# Accepts both the canonical host (git.lyrebirdsynth.net) and its legacy alias
|
||||
# (realizedsound.mooo.com) — a DNS CNAME to the same gitea server.
|
||||
RELEASE_REMOTE_REGEX='(git\.lyrebirdsynth\.net|realizedsound\.mooo\.com).*/Lyrebird(\.git)?/?$'
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
@@ -66,7 +68,7 @@ fail() { echo "ERROR: $*" >&2; exit 1; }
|
||||
|
||||
RELEASE_URL="$(git -C "$RELEASE" remote get-url origin 2>/dev/null || echo "")"
|
||||
if [[ ! "$RELEASE_URL" =~ $RELEASE_REMOTE_REGEX ]]; then
|
||||
fail "release origin ('$RELEASE_URL') is not the Lyrebird mooo release repo (must match /$RELEASE_REMOTE_REGEX/) — refusing to sync. Wrong --release path?"
|
||||
fail "release origin ('$RELEASE_URL') is not the Lyrebird gitea release repo (must match /$RELEASE_REMOTE_REGEX/) — refusing to sync. Wrong --release path?"
|
||||
fi
|
||||
|
||||
# --- Guard: dev working tree should be committed (we archive HEAD) -----------
|
||||
|
||||
@@ -1,13 +1,45 @@
|
||||
---
|
||||
name: lyrebird_release_prep
|
||||
description: Prepare the public LyrebirdRelease (mooo) repo from the Lyrebird dev repo, replacing the manual "export → hand-copy in Finder" step. Syncs the dev repo's committed tree into the release working tree, excluding maintainer-only paths that never ship (legacy/, PLAN.md, .claude/, .githooks/, .swiftpm/) and cleaning accumulated Finder duplicate cruft. Dry-run first, then apply, then guides commit + tag + push to mooo. Use when cutting a new Lyrebird release (e.g. bumping to a new vX.Y.Z tag).
|
||||
description: Prepare the public LyrebirdRelease repo from the Lyrebird dev repo, replacing the manual "export → hand-copy in Finder" step. Syncs the dev repo's committed tree into the release working tree, excluding maintainer-only paths that never ship (legacy/, PLAN.md, .claude/, .githooks/, .swiftpm/) and cleaning accumulated Finder duplicate cruft. Dry-run first, then apply, then guides commit + tag + push to the gitea host. Use when cutting a new Lyrebird release (e.g. bumping to a new vX.Y.Z tag), and read it before ANY `git push` in Lyrebird, LyrebirdRelease or ShoeGaze: it records which remote is the private working repo (Bitbucket) and which is public (git.lyrebirdsynth.net, formerly realizedsound.mooo.com).
|
||||
---
|
||||
|
||||
# Lyrebird Release Prep
|
||||
|
||||
Replicates the Lyrebird **dev** repo (`~/Documents/src/Lyrebird`, origin = bitbucket) into
|
||||
the public **release** repo (`~/Documents/src/LyrebirdRelease`, origin = `realizedsound.mooo.com`)
|
||||
that SwiftPM consumers resolve from — without the manual Finder export/hand-copy.
|
||||
the public **release** repo (`~/Documents/src/LyrebirdRelease`, origin = `git.lyrebirdsynth.net`,
|
||||
formerly `realizedsound.mooo.com` — a CNAME to the same server) that SwiftPM consumers
|
||||
resolve from — without the manual Finder export/hand-copy.
|
||||
|
||||
## Remotes: where each repo pushes (read before any `git push`)
|
||||
|
||||
Two kinds of remote, with different rules:
|
||||
|
||||
| Repo | Local path | `origin` | Role |
|
||||
|---|---|---|---|
|
||||
| **Lyrebird** (dev) | `~/Documents/src/Lyrebird` | `git@bitbucket.org:realizedsound/lyrebird.git` | **Working repo, Bitbucket.** Private. Day-to-day commits, branches and WIP, including the maintainer-only paths listed below. Push here freely as work progresses. |
|
||||
| **LyrebirdRelease** | `~/Documents/src/LyrebirdRelease` | `ssh://git@git.lyrebirdsynth.net:2222/josh/Lyrebird.git` | **Public gitea.** Every commit and tag pushed here is publicly visible, and SwiftPM consumers resolve from it. Only ever updated through this skill (sync, commit, tag, push), at release time. |
|
||||
| **ShoeGaze** | `~/Documents/src/ShoeGaze` | `https://git.lyrebirdsynth.net/josh/ShoeGaze/` | **Public gitea.** No Bitbucket remote, so a push here is public. It depends on a published Lyrebird tag. |
|
||||
|
||||
The public gitea host is `git.lyrebirdsynth.net` (a DNS CNAME to `realizedsound.mooo.com`, the
|
||||
former hostname — both resolve to the same server, so old `mooo` URLs still work). "gitea" below
|
||||
means that public host.
|
||||
|
||||
Rules:
|
||||
1. **Bitbucket = working directory, gitea = public releases and commits.** Never push the dev repo
|
||||
to gitea, and never push maintainer-only files (`legacy/`, `PLAN.md`, `DOC_UPDATE_PLAN.md`,
|
||||
the two phase-planning docs, `.claude/`, `.githooks/`) or anything private to a public remote.
|
||||
2. Before anything goes to gitea, read the commit list and the file list as if a stranger will:
|
||||
no secrets, no private notes, no personal paths.
|
||||
3. Claude prepares (dry run, apply, commit message, tag), then **the maintainer runs the push**
|
||||
(it needs his key/touch). Claude does not push to gitea on its own.
|
||||
4. A ShoeGaze push to gitea is public too: confirm it builds against the tagged Lyrebird release
|
||||
it declares, not a local `swift package edit` override.
|
||||
|
||||
The gitea server (noted 2026-10-23): Gitea running in Docker on the Mac mini, reached at
|
||||
`git.lyrebirdsynth.net` (CNAME to `realizedsound.mooo.com`). It is written in Go, so the PHP2Shell
|
||||
vulnerability does not apply to it, but it is internet-facing: keep Gitea and the Docker host
|
||||
updated. If it is slow or unreachable (it intermittently was on 2026-10-23), check the Mac mini
|
||||
before suspecting the repo.
|
||||
|
||||
## What it does (and why it's safe)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ defined promotion path between them.
|
||||
| Remote | Role | Cadence |
|
||||
|---|---|---|
|
||||
| **Bitbucket** (`origin`) | Active development — fine-grained commits, experiments, in-progress branches, frequent pushes. | Continuous. Whatever your working rhythm is. |
|
||||
| **Gitea** (`realizedsound.mooo.com/josh/Lyrebird`) | Release / distribution — the repo external consumers pull as a SwiftPM dependency. | Deliberate. Only when a coherent set of features is ready. |
|
||||
| **Gitea** (`git.lyrebirdsynth.net/josh/Lyrebird`) | Release / distribution — the repo external consumers pull as a SwiftPM dependency. | Deliberate. Only when a coherent set of features is ready. |
|
||||
|
||||
The two are **not** mirrors. Bitbucket holds the full granular history; Gitea
|
||||
receives **consolidated** promotions when a feature set is release-ready.
|
||||
|
||||
@@ -78,7 +78,7 @@ let package = Package(
|
||||
// Pin tightly to the Lyrebird MINOR range — @_spi(LyrebirdExtensions)
|
||||
// symbols are documented as MINOR-mutable.
|
||||
.package(
|
||||
url: "https://realizedsound.mooo.com/josh/Lyrebird.git",
|
||||
url: "https://git.lyrebirdsynth.net/josh/Lyrebird.git",
|
||||
"0.9.1" ..< "1.0.0"
|
||||
),
|
||||
],
|
||||
@@ -112,7 +112,7 @@ If you are pulling Lyrebird from a private repository, use the SSH URL form:
|
||||
|
||||
```swift
|
||||
.package(
|
||||
url: "git@realizedsound.mooo.com:josh/Lyrebird.git",
|
||||
url: "git@git.lyrebirdsynth.net:josh/Lyrebird.git",
|
||||
"0.9.1" ..< "1.0.0"
|
||||
)
|
||||
```
|
||||
|
||||
@@ -42,7 +42,7 @@ let package = Package(
|
||||
platforms: [.macOS(.v15)],
|
||||
dependencies: [
|
||||
// Lyrebird, fetched from its git host:
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.0.0"),
|
||||
.package(url: "https://git.lyrebirdsynth.net/josh/Lyrebird", from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
|
||||
@@ -124,6 +124,35 @@ swift run # a 440 Hz sine for a few seconds
|
||||
built with `LYREBIRD_DISABLE_ALSA=1`), in which case `makeDefaultAudioDriver()`
|
||||
returns a silent `OfflineDriver`.
|
||||
|
||||
### The bundled CLI demos
|
||||
|
||||
The scaffold templates above make a *new* project. To run the demos that ship in
|
||||
this repo instead, each lives in its own package under `Demos/` and runs with
|
||||
`swift run` from its folder — the same source as the macOS Xcode schemes:
|
||||
|
||||
```bash
|
||||
(cd Demos/LyrebirdNRTDemo && swift run) # offline render → ./nrt_output.wav (no audio device)
|
||||
(cd Demos/LyrebirdQuickstartDemo && swift run) # a 440 Hz sine (needs libasound + a device)
|
||||
(cd Demos/LyrebirdDemo && swift run) # reverb smoke-test through the default output
|
||||
(cd Demos/LyrebirdScoreDemo && swift run) # notated Score → MusicXML + a rendered WAV (no device)
|
||||
```
|
||||
|
||||
`LyrebirdNRTDemo` and `LyrebirdScoreDemo` write a WAV off Apple (CAF is Apple-only)
|
||||
into the current directory; the live demos use `makeDefaultAudioDriver()` →
|
||||
`ALSAAudioDriver`.
|
||||
|
||||
There is also a cross-platform **GUI** demo — `Demos/LyrebirdGUIDemo` — whose synths
|
||||
and views are one shared source that bootstraps SwiftUI on macOS and GTK4 on Linux.
|
||||
It needs `libgtk-4-dev` + `libgtksourceview-5-dev` (and `libasound2-dev` + a device
|
||||
for sound):
|
||||
|
||||
```bash
|
||||
(cd Demos/LyrebirdGUIDemo && swift run) # vector oscillator (default)
|
||||
(cd Demos/LyrebirdGUIDemo && LYREBIRD_DEMO=sine swift run) # stereo sine tone
|
||||
```
|
||||
|
||||
The AUv3 / iOS / `LyrebirdMacOSDemo` GUI demos are Apple-only.
|
||||
|
||||
### REPL and live coding
|
||||
|
||||
```bash
|
||||
|
||||
@@ -68,7 +68,7 @@ Each Xcode-project template lays out:
|
||||
└── ...
|
||||
```
|
||||
|
||||
Lyrebird is pulled in via a remote SPM dependency on `https://realizedsound.mooo.com/josh/Lyrebird` (configurable via `ProjectScaffolder.lyrebirdPackageURL`). The scaffolded project lives anywhere on disk and does not need a local checkout.
|
||||
Lyrebird is pulled in via a remote SPM dependency on `https://git.lyrebirdsynth.net/josh/Lyrebird` (configurable via `ProjectScaffolder.lyrebirdPackageURL`). The scaffolded project lives anywhere on disk and does not need a local checkout.
|
||||
|
||||
### Distribution & microphone input
|
||||
|
||||
@@ -117,7 +117,7 @@ let package = Package(
|
||||
name: "MyPiece",
|
||||
platforms: [.macOS(.v15)],
|
||||
dependencies: [
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.0.0"),
|
||||
.package(url: "https://git.lyrebirdsynth.net/josh/Lyrebird", from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
|
||||
@@ -177,7 +177,7 @@ Open `MyPiece/Package.swift` and update the placeholder URL to the published
|
||||
Lyrebird repository:
|
||||
|
||||
```swift
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.0.0"),
|
||||
.package(url: "https://git.lyrebirdsynth.net/josh/Lyrebird", from: "1.0.0"),
|
||||
```
|
||||
|
||||
Resolve the dependency graph:
|
||||
|
||||
Reference in New Issue
Block a user