06bdcbbe92
- 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>
71 lines
2.5 KiB
Swift
71 lines
2.5 KiB
Swift
// 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()
|
|
}
|
|
}
|