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
|
||||
|
||||
@@ -97,7 +98,7 @@ public struct LyrebirdSynthView: View {
|
||||
}
|
||||
|
||||
/// One discovered `@UIParam` slot, paired with its display name + range.
|
||||
public struct Entry: Identifiable {
|
||||
public struct Entry: Identifiable, Sendable {
|
||||
public let id: String
|
||||
public let propertyName: String
|
||||
public let displayName: String
|
||||
@@ -173,3 +174,129 @@ public let lyrebirdSynthViewDefaultMin: Double = 0
|
||||
|
||||
/// Default upper bound used when `parameterMetadata` does not supply a range.
|
||||
public let lyrebirdSynthViewDefaultMax: Double = 1
|
||||
|
||||
#else
|
||||
// Linux/GTK4 counterpart to `LyrebirdUI.LyrebirdSynthView`: an auto-generated
|
||||
// parameter grid for a `SynthesizerBase` subclass, one ``ParameterKnob`` per
|
||||
// `@UIParam` slot. The `@UIParam` discovery (`Mirror` walk), the ``Entry`` type,
|
||||
// and the range/default constants are identical to the Apple side — only the
|
||||
// `body` swaps the SwiftUI `ScrollView`/`LazyVGrid` for SwiftOpenUI's data-based
|
||||
// `LazyVGrid` (`columns:data:content:`, no per-item ForEach). Adaptive columns
|
||||
// map onto GtkGridView's min-column-count behaviour.
|
||||
//
|
||||
// SwiftOpenUI is always present in this target (see Package.swift), so no
|
||||
// `canImport` guard is needed.
|
||||
import SwiftOpenUI
|
||||
import LyrebirdSynth
|
||||
|
||||
/// Auto-generated parameter grid for a `SynthesizerBase` subclass on Linux/GTK4.
|
||||
/// Mirrors `LyrebirdUI.LyrebirdSynthView`: walks the synth's `Mirror` chain for
|
||||
/// `@UIParam` slots and renders one ``ParameterKnob`` per slot in an adaptive
|
||||
/// grid. Same public API/init as the Apple side.
|
||||
///
|
||||
/// **`@UIParam` only.** `@LiveParam` slots are skipped — they have no
|
||||
/// `@Observable` projected value to drive a knob.
|
||||
public struct LyrebirdSynthView: View {
|
||||
|
||||
public let entries: [Entry]
|
||||
|
||||
/// - Parameter synth: The `SynthesizerBase` instance to introspect.
|
||||
///
|
||||
/// > Note: The Apple side also accepts a `[String: LyrebirdAUParameterInfo]`
|
||||
/// > metadata dictionary for per-knob ranges, but that type lives under
|
||||
/// > `#if canImport(AudioToolbox)` (Apple-only), so on Linux every slot uses
|
||||
/// > the default `lyrebirdSynthViewDefaultMin...Max` range. Pass pre-built
|
||||
/// > ``Entry`` values via `init(entries:)` for custom ranges.
|
||||
public init(synth: SynthesizerBase) {
|
||||
self.entries = LyrebirdSynthView.discover(synth: synth)
|
||||
}
|
||||
|
||||
/// - Parameter entries: Pre-built list of discovered entries.
|
||||
public init(entries: [Entry]) {
|
||||
self.entries = entries
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
ScrollView {
|
||||
LazyVGrid(
|
||||
columns: [GridItem(.adaptive(minimum: lyrebirdSynthViewColumnMinWidth))],
|
||||
data: entries
|
||||
) { entry in
|
||||
ParameterKnob(
|
||||
entry.displayName,
|
||||
node: entry.node,
|
||||
range: entry.range
|
||||
)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
/// One discovered `@UIParam` slot, paired with its display name + range.
|
||||
public struct Entry: Identifiable, Sendable {
|
||||
public let id: String
|
||||
public let propertyName: String
|
||||
public let displayName: String
|
||||
public let node: UIParamNode
|
||||
public let range: ClosedRange<Double>
|
||||
|
||||
public init(
|
||||
propertyName: String,
|
||||
displayName: String,
|
||||
node: UIParamNode,
|
||||
range: ClosedRange<Double>
|
||||
) {
|
||||
self.id = propertyName
|
||||
self.propertyName = propertyName
|
||||
self.displayName = displayName
|
||||
self.node = node
|
||||
self.range = range
|
||||
}
|
||||
}
|
||||
|
||||
/// Walks the synth's `Mirror` (with superclass chain) looking for `@UIParam`
|
||||
/// properties and emits one ``Entry`` per slot. Slot order matches the
|
||||
/// `Mirror` walk used by `SynthesizerBase._autoRegisterLiveParams()`. Every
|
||||
/// slot uses the default range (no `LyrebirdAUParameterInfo` on Linux).
|
||||
public static func discover(synth: SynthesizerBase) -> [Entry] {
|
||||
var entries: [Entry] = []
|
||||
var mirrors: [Mirror] = []
|
||||
var current: Mirror? = Mirror(reflecting: synth)
|
||||
while let m: Mirror = current {
|
||||
mirrors.append(m)
|
||||
current = m.superclassMirror
|
||||
}
|
||||
let range: ClosedRange<Double> = lyrebirdSynthViewDefaultMin...lyrebirdSynthViewDefaultMax
|
||||
for mirror: Mirror in mirrors.reversed() {
|
||||
for child: Mirror.Child in mirror.children {
|
||||
guard let label: String = child.label else { continue }
|
||||
let key: String = label.hasPrefix("_") ? String(label.dropFirst()) : label
|
||||
guard let wrapper: any LiveParameterWrapper = child.value as? LiveParameterWrapper else { continue }
|
||||
guard let node: UIParamNode = wrapper._projectedAsValidInput as? UIParamNode else { continue }
|
||||
entries.append(Entry(
|
||||
propertyName: key,
|
||||
displayName: key,
|
||||
node: node,
|
||||
range: range
|
||||
))
|
||||
}
|
||||
}
|
||||
return entries
|
||||
}
|
||||
}
|
||||
|
||||
/// Minimum column width (points) for ``LyrebirdSynthView``'s adaptive grid.
|
||||
public let lyrebirdSynthViewColumnMinWidth: Double = 120
|
||||
|
||||
// NOTE: the Apple side's `lyrebirdSynthViewGridSpacing` / `lyrebirdSynthViewItemSpacing`
|
||||
// are intentionally absent on Linux — SwiftOpenUI's `LazyVGrid(columns:data:content:)`
|
||||
// exposes no per-item spacing parameter (grid layout is driven by GtkGridView's
|
||||
// column count), so there is nothing to apply them to. The Linux grid uses
|
||||
// GtkGridView's default gutter.
|
||||
|
||||
/// Default lower bound used when `parameterMetadata` does not supply a range.
|
||||
public let lyrebirdSynthViewDefaultMin: Double = 0
|
||||
|
||||
/// Default upper bound used when `parameterMetadata` does not supply a range.
|
||||
public let lyrebirdSynthViewDefaultMax: Double = 1
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user