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:
2026-09-10 21:09:11 -07:00
parent 77580ee98e
commit b6fdee8bfc
293 changed files with 16800 additions and 775 deletions
@@ -4,6 +4,7 @@
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
#if canImport(SwiftUI)
import SwiftUI
import LyrebirdSynth
@@ -133,3 +134,126 @@ public struct MultiSlider: View {
)
}
}
#else
// Linux/GTK4 counterpart to `LyrebirdUI.MultiSlider`: a row of `count` vertical
// bars bound to consecutive `LyrebirdBuffer` cells, drawn on a `Canvas` with an
// `.onDrag` gesture (the same custom-drawn approach as `ParameterSlider`). The
// SwiftUI `GeometryReader`/`ZStack`/`DragGesture` are replaced: the Canvas has a
// fixed total width (`count × columnWidth`) so the drag maps pointer-x to a
// column directly, and pointer-y over the fixed `height` gives the value — a
// Canvas renderer gets its `size`, so no `GeometryReader` is needed. Per-bar
// writes go through `LyrebirdBuffer.setValue(_:at:)` exactly as on the Apple side.
//
// SwiftOpenUI + BackendGTK4 are always present in this target (see Package.swift).
import SwiftOpenUI
import BackendGTK4
import LyrebirdSynth
import Foundation
/// A row of adjacent vertical sliders bound to a `LyrebirdBuffer` for the
/// Linux/GTK4 UI. Mirrors `LyrebirdUI.MultiSlider`; same public API/init as the
/// Apple side.
public struct MultiSlider: View {
// MARK: - Configuration
private let buffer: LyrebirdBuffer
private let count: Int
private let startIndex: Int
private let range: ClosedRange<Double>
private let height: CGFloat
// MARK: - State
@State private var values: [Double]
// Fixed per-column width (points). The Apple side fills the available width
// via GeometryReader; on Linux the Canvas needs a concrete width, so each bar
// gets a fixed column and the row is `count × columnWidth` wide.
private let columnWidth: Double = 14
// MARK: - Init
/// - Parameters:
/// - buffer: Backing `LyrebirdBuffer`. Mono only. Initial values are read
/// once from `buffer[startIndex + i]` at construction.
/// - count: Number of sliders. Must be ≥ 1 and `startIndex + count <= buffer.count`.
/// - startIndex: First buffer index this view writes to. Defaults to `0`.
/// - range: Value range. Bar-top maps to `range.upperBound`, bar-bottom to
/// `range.lowerBound`.
/// - height: View height in points. Default `100`.
public init(
buffer: LyrebirdBuffer,
count: Int,
startIndex: Int = 0,
range: ClosedRange<Double>,
height: CGFloat = 100
) {
precondition(buffer.channelCount == 1,
"MultiSlider: buffer must be mono, got channelCount=\(buffer.channelCount)")
precondition(count >= 1,
"MultiSlider: count must be >= 1, got \(count)")
precondition(startIndex >= 0 && startIndex + count <= buffer.count,
"MultiSlider: startIndex \(startIndex) + count \(count) "
+ "exceeds buffer.count \(buffer.count)")
precondition(range.lowerBound < range.upperBound,
"MultiSlider: range must be non-empty, got \(range)")
self.buffer = buffer
self.count = count
self.startIndex = startIndex
self.range = range
self.height = height
var initial: [Double] = [Double](repeating: range.lowerBound, count: count)
for i: Int in 0..<count {
let raw: Double = buffer[startIndex + i]
initial[i] = min(max(raw, range.lowerBound), range.upperBound)
}
_values = State(wrappedValue: initial)
}
// MARK: - Body
public var body: some View {
let totalWidth: Double = Double(count) * columnWidth
return Canvas(renderer: { (ctx: DrawingContext, size: CGSize) in
let h: Double = Double(size.height)
let w: Double = columnWidth
// Panel background.
ctx.setColor(r: 0.5, g: 0.5, b: 0.5, a: 0.08)
ctx.rectangle(x: 0, y: 0, width: Double(size.width), height: h)
ctx.fill()
// Bars.
let span: Double = range.upperBound - range.lowerBound
ctx.setColor(r: 0.30, g: 0.80, b: 1.0)
for i: Int in 0..<count {
let v: Double = values[i]
let norm: Double = (v - range.lowerBound) / span
let barH: Double = h * norm
let x: Double = Double(i) * w
ctx.rectangle(x: x + 1, y: h - barH, width: max(1, w - 2), height: barH)
ctx.fill()
}
})
.frame(width: totalWidth, height: Double(height))
.onDrag(
minimumDistance: 0,
onChanged: { (drag: DragGestureValue) in
let column: Int = Int(drag.location.x / columnWidth)
guard column >= 0 && column < count else { return }
let hgt: Double = Double(height)
let yClamped: Double = min(max(drag.location.y, 0), hgt)
let norm: Double = 1 - (yClamped / hgt)
let span: Double = range.upperBound - range.lowerBound
let value: Double = range.lowerBound + norm * span
values[column] = value
buffer.setValue(value, at: startIndex + column)
}
)
}
}
#endif