v2.3.1 release: cross-platform LyrebirdGUIDemo + Linux demo ports + doc refresh
- New Demos/LyrebirdGUIDemo: one shared source (synths + node-based views) that bootstraps SwiftUI on macOS and GTK4/SwiftOpenUI on Linux; LYREBIRD_DEMO=vector|sine. - The four CLI demos (Quickstart/Demo/NRT/Score) now build and run on Linux. - README + Linux getting-started refreshed; LyrebirdATK row removed from the Extensions section pending collaborator sign-off. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user