// ConductorDemoView.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT #if canImport(SwiftUI) import SwiftUI #endif import LyrebirdSynth import LyrebirdUI /// Demonstrates ``EventConductor``: start the engine, then toggle a top and a bottom part on and /// off. Each part loops forever while on and enters on the next beat of the conductor's clock, so /// the two lock together however late they are pressed. Includes the CPU status strip and an /// oscilloscope. /// /// Written to the View-DSL subset shared by SwiftUI and SwiftOpenUI, so it runs on macOS and Linux. /// Buttons use the `action:label:` form, which fires reliably on both backends. public struct ConductorDemoView: View { let scope: ScopeCapture let engine: SynthesisEngine @State private var controller: ConductorDemoController public init(scope: ScopeCapture, engine: SynthesisEngine) { self.scope = scope self.engine = engine _controller = State(wrappedValue: ConductorDemoController(engine: engine)) } public var body: some View { VStack { Text("Lyrebird — Event Conductor") .font(.headline) Button { controller.toggleEngine() } label: { Text(controller.engineRunning ? "Stop Engine" : "Start Engine") } Button { controller.toggleTop() } label: { Text(controller.topOn ? "Top Part: ON (tap to stop)" : "Top Part: off (starts on next beat)") } .disabled(!controller.engineRunning) Button { controller.toggleBottom() } label: { Text(controller.bottomOn ? "Bottom Part: ON (tap to stop)" : "Bottom Part: off (starts on next beat)") } .disabled(!controller.engineRunning) LyrebirdStatusView(engine: engine) LyrebirdScopeView(capture: scope) .frame(height: 120) } .padding() } }