Lyrebird 2.0.0 — Linux support
Consolidated release: the cross-platform Linux port (engine, generators, CLI, REPL, NRT, portable DSP), live ALSA audio + ALSA MIDI + POSIX OSC + portable WAV codec, the GTK4 GUI (LyrebirdUI on the SwiftOpenUI backend), and the Linux live-coding scratchpad (LiveCompile). Apple platforms unchanged; all additive. See RELEASES.md and LINUX_README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if canImport(SwiftUI)
|
||||
import SwiftUI
|
||||
import LyrebirdSynth
|
||||
|
||||
@@ -163,3 +164,180 @@ extension LyrebirdEventListPerformanceView {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
// Linux/GTK4 counterpart to `LyrebirdUI.LyrebirdEventListPerformanceView`: a
|
||||
// ``LyrebirdEventListView`` on top plus a live stack of ``LyrebirdProcessView``
|
||||
// strips, one per running process. The 10 Hz membership poll moves off
|
||||
// SwiftOpenUI's off-main `.task` onto a `Timer` on `RunLoop.main` inside an
|
||||
// `@Observable` model, keeping the identity-stable reassignment so child strips
|
||||
// keep their own timers/state across ticks.
|
||||
//
|
||||
// SwiftOpenUI is always present in this target (see Package.swift).
|
||||
import SwiftOpenUI
|
||||
import LyrebirdSynth
|
||||
import Observation
|
||||
import Foundation
|
||||
|
||||
/// 10 Hz — matches ``LyrebirdProcessView`` / ``LyrebirdEventListView``.
|
||||
private let linuxEventListPerformancePollIntervalSeconds: TimeInterval = 0.1
|
||||
|
||||
/// Polls an event list's running processes on a main-thread timer and publishes
|
||||
/// an identity-stable snapshot for ``LyrebirdEventListPerformanceView``. Internal.
|
||||
///
|
||||
/// `@unchecked Sendable`: main-thread-confined; the `Timer` block is `@Sendable`,
|
||||
/// same rationale as `LyrebirdScopeModel`.
|
||||
@Observable
|
||||
final class LinuxEventListPerformanceModel: @unchecked Sendable {
|
||||
|
||||
var runningProcesses: [LyrebirdProcess] = []
|
||||
|
||||
@ObservationIgnored private var timer: Timer?
|
||||
@ObservationIgnored private let eventList: LyrebirdEventList
|
||||
|
||||
init(eventList: LyrebirdEventList) {
|
||||
self.eventList = eventList
|
||||
}
|
||||
|
||||
deinit {
|
||||
timer?.invalidate()
|
||||
}
|
||||
|
||||
func start() {
|
||||
guard timer == nil else { return }
|
||||
refresh()
|
||||
let t: Timer = Timer.scheduledTimer(
|
||||
withTimeInterval: linuxEventListPerformancePollIntervalSeconds,
|
||||
repeats: true
|
||||
) { [weak self] _ in
|
||||
self?.refresh()
|
||||
}
|
||||
timer = t
|
||||
}
|
||||
|
||||
func stop() {
|
||||
timer?.invalidate()
|
||||
timer = nil
|
||||
}
|
||||
|
||||
func refresh() {
|
||||
let snapshot: [LyrebirdProcess] = eventList.allProcesses.filter { $0.isRunning }
|
||||
if !snapshot.elementsEqualByIdentity(to: runningProcesses) {
|
||||
runningProcesses = snapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A composite event-list performance view for the Linux/GTK4 UI. Mirrors
|
||||
/// `LyrebirdUI.LyrebirdEventListPerformanceView`; same public API/init as the
|
||||
/// Apple side.
|
||||
public struct LyrebirdEventListPerformanceView: View {
|
||||
|
||||
public let eventList: LyrebirdEventList
|
||||
public let engine: SynthesisEngine
|
||||
|
||||
@State private var model: LinuxEventListPerformanceModel
|
||||
|
||||
/// Creates a performance view bound to the given event list.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - eventList: The `LyrebirdEventList` to drive.
|
||||
/// - engine: The `SynthesisEngine` that hosts both the list and any ad-hoc
|
||||
/// `Start` actions on individual process strips.
|
||||
public init(
|
||||
eventList: LyrebirdEventList,
|
||||
engine: SynthesisEngine
|
||||
) {
|
||||
self.eventList = eventList
|
||||
self.engine = engine
|
||||
_model = State(wrappedValue: LinuxEventListPerformanceModel(eventList: eventList))
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
LyrebirdEventListView(eventList: eventList)
|
||||
|
||||
Divider()
|
||||
|
||||
if model.runningProcesses.isEmpty {
|
||||
emptyState
|
||||
} else {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
ForEach(model.runningProcesses, id: \.identityKey) { proc in
|
||||
LyrebirdProcessView(process: proc, engine: engine)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(12)
|
||||
.background(Color.lyrebirdControlBackground)
|
||||
.frame(minWidth: 360, minHeight: 320)
|
||||
.onAppear { model.start() }
|
||||
.onDisappear { model.stop() }
|
||||
}
|
||||
|
||||
private var emptyState: some View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("No processes running")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
Text("Press Next to fire the queued event.")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Stable identity for ForEach
|
||||
|
||||
private extension LyrebirdProcess {
|
||||
/// `ObjectIdentifier`-based key used for `ForEach` so processes with
|
||||
/// duplicate user-supplied `id` strings still render distinct views.
|
||||
var identityKey: ObjectIdentifier { ObjectIdentifier(self) }
|
||||
}
|
||||
|
||||
private extension Array where Element == LyrebirdProcess {
|
||||
func elementsEqualByIdentity(to other: [LyrebirdProcess]) -> Bool {
|
||||
guard count == other.count else { return false }
|
||||
for (a, b) in zip(self, other) where a !== b { return false }
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Standalone window (Linux)
|
||||
|
||||
extension LyrebirdEventListPerformanceView {
|
||||
|
||||
/// Opens a `LyrebirdWindow` hosting an event-list performance view. Requires
|
||||
/// a running `GtkApplication` loop.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - eventList: The `LyrebirdEventList` to drive.
|
||||
/// - engine: The `SynthesisEngine` for individual process Start actions.
|
||||
/// - title: Window title-bar text. Defaults to the event list ID.
|
||||
/// - width: Initial window width in points. Defaults to `420`.
|
||||
/// - height: Initial window height in points. Defaults to `520`.
|
||||
/// - Returns: The `LyrebirdWindow` hosting the view.
|
||||
@discardableResult
|
||||
public static func presentInWindow(
|
||||
eventList: LyrebirdEventList,
|
||||
engine: SynthesisEngine,
|
||||
title: String? = nil,
|
||||
width: Double = 420,
|
||||
height: Double = 520
|
||||
) -> LyrebirdWindow {
|
||||
let win: LyrebirdWindow = LyrebirdWindow(
|
||||
title: title ?? eventList.id,
|
||||
width: width,
|
||||
height: height
|
||||
)
|
||||
win.open {
|
||||
LyrebirdEventListPerformanceView(eventList: eventList, engine: engine)
|
||||
}
|
||||
return win
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user