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:
@@ -14,7 +14,9 @@ public enum ProjectTemplate: String, CaseIterable, Equatable {
|
||||
/// `main` that plays a 440 Hz tone for ten seconds and exits. The fastest way
|
||||
/// to hear Lyrebird after installing the CLI.
|
||||
case quickstart = "quickstart"
|
||||
/// Minimal engine setup with `CoreAudioDriver` and `RunLoop.main.run()`.
|
||||
/// Minimal engine setup with the platform's live-audio driver
|
||||
/// (`CoreAudioDriver` on Apple, `ALSAAudioDriver` on Linux) and
|
||||
/// `RunLoop.main.run()`.
|
||||
case basic = "basic"
|
||||
/// Real-time demo: `SineTone` synthesizer with `@LiveParam` frequency and amplitude.
|
||||
case demo = "demo"
|
||||
@@ -474,14 +476,20 @@ public enum ProjectScaffolder {
|
||||
}
|
||||
}
|
||||
|
||||
// Lyrebird picks the platform's live-audio driver: Core Audio on Apple,
|
||||
// ALSA on a Linux build with libasound. Where no live backend exists it
|
||||
// returns an OfflineDriver, which runs the graph but makes no sound —
|
||||
// `isLiveAudioAvailable` says which you got.
|
||||
let driver: any AudioDriver = makeDefaultAudioDriver()
|
||||
|
||||
do {
|
||||
// The engine owns Core Audio and runs the graph on the RT thread.
|
||||
// The engine owns the audio device and runs the graph on the RT thread.
|
||||
let engine = SynthesisEngine(
|
||||
blockSize: \(scaffoldDefaultBlockSize),
|
||||
sampleRate: \(scaffoldDefaultSampleRate),
|
||||
numOutputChannels: \(scaffoldDefaultOutputChannels),
|
||||
numInputChannels: 0,
|
||||
driver: CoreAudioDriver()
|
||||
driver: driver
|
||||
)
|
||||
|
||||
try engine.start() // opens the output device
|
||||
@@ -506,13 +514,19 @@ public enum ProjectScaffolder {
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
// Lyrebird picks the platform's live-audio driver: Core Audio on Apple,
|
||||
// ALSA on a Linux build with libasound. Where no live backend exists it
|
||||
// returns an OfflineDriver, which runs the graph but makes no sound —
|
||||
// `isLiveAudioAvailable` says which you got.
|
||||
let driver: any AudioDriver = makeDefaultAudioDriver()
|
||||
|
||||
// Configure the synthesis engine.
|
||||
let engine = SynthesisEngine(
|
||||
blockSize: \(scaffoldDefaultBlockSize),
|
||||
sampleRate: \(scaffoldDefaultSampleRate),
|
||||
numOutputChannels: \(scaffoldDefaultOutputChannels),
|
||||
numInputChannels: \(scaffoldDefaultInputChannels),
|
||||
driver: CoreAudioDriver()
|
||||
driver: driver
|
||||
)
|
||||
|
||||
// Add your Synthesizers here.
|
||||
@@ -551,12 +565,18 @@ public enum ProjectScaffolder {
|
||||
|
||||
// MARK: - Main
|
||||
|
||||
// Lyrebird picks the platform's live-audio driver: Core Audio on Apple,
|
||||
// ALSA on a Linux build with libasound. Where no live backend exists it
|
||||
// returns an OfflineDriver, which runs the graph but makes no sound —
|
||||
// `isLiveAudioAvailable` says which you got.
|
||||
let driver: any AudioDriver = makeDefaultAudioDriver()
|
||||
|
||||
let engine = SynthesisEngine(
|
||||
blockSize: \(scaffoldDefaultBlockSize),
|
||||
sampleRate: \(scaffoldDefaultSampleRate),
|
||||
numOutputChannels: \(scaffoldDefaultOutputChannels),
|
||||
numInputChannels: \(scaffoldDefaultInputChannels),
|
||||
driver: CoreAudioDriver()
|
||||
driver: driver
|
||||
)
|
||||
|
||||
do {
|
||||
@@ -625,9 +645,19 @@ public enum ProjectScaffolder {
|
||||
}
|
||||
}
|
||||
|
||||
// Diagnostics go to stderr. Written through FileHandle rather than
|
||||
// `fputs(_:stderr)` because Swift 6 rejects the imported C `stderr`
|
||||
// global as not concurrency-safe on Linux.
|
||||
func printError(_ message: String) {
|
||||
FileHandle.standardError.write(Data(message.utf8))
|
||||
}
|
||||
|
||||
// MARK: - Render
|
||||
|
||||
let outputURL = URL(fileURLWithPath: "output.caf")
|
||||
// WAV, not CAF: CAF is an Apple container, and NRTDriver throws
|
||||
// `unsupportedFormatOnPlatform` for it off Apple. A scaffolded project
|
||||
// should run everywhere it compiles.
|
||||
let outputURL = URL(fileURLWithPath: "output.wav")
|
||||
let renderDuration = \(scaffoldDefaultNRTDuration)
|
||||
|
||||
let engine = SynthesisEngine(
|
||||
@@ -635,14 +665,14 @@ public enum ProjectScaffolder {
|
||||
sampleRate: \(scaffoldDefaultSampleRate),
|
||||
numOutputChannels: \(scaffoldDefaultOutputChannels),
|
||||
numInputChannels: 0,
|
||||
driver: NRTDriver(outputURL: outputURL, duration: renderDuration)
|
||||
driver: NRTDriver(outputURL: outputURL, duration: renderDuration, format: .wavFloat32)
|
||||
)
|
||||
|
||||
// Add synthesizers BEFORE start() — NRTDriver renders synchronously inside start().
|
||||
do {
|
||||
try engine.add(\(name)Synth())
|
||||
} catch {
|
||||
fputs("engine.add failed: \\(error)\\n", stderr)
|
||||
printError("engine.add failed: \\(error)\\n")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
@@ -650,7 +680,7 @@ public enum ProjectScaffolder {
|
||||
try engine.start()
|
||||
print("Rendered \\(renderDuration)s → \\(outputURL.path)")
|
||||
} catch {
|
||||
fputs("Render failed: \\(error)\\n", stderr)
|
||||
printError("Render failed: \\(error)\\n")
|
||||
exit(1)
|
||||
}
|
||||
"""
|
||||
@@ -744,6 +774,13 @@ public enum ProjectScaffolder {
|
||||
}
|
||||
}
|
||||
|
||||
// Diagnostics go to stderr. Written through FileHandle rather than
|
||||
// `fputs(_:stderr)` because Swift 6 rejects the imported C `stderr`
|
||||
// global as not concurrency-safe on Linux.
|
||||
func printError(_ message: String) {
|
||||
FileHandle.standardError.write(Data(message.utf8))
|
||||
}
|
||||
|
||||
// MARK: - Output location
|
||||
|
||||
// Write next to this project's source rather than the launch directory.
|
||||
@@ -762,7 +799,7 @@ public enum ProjectScaffolder {
|
||||
try xml.write(to: xmlURL, atomically: true, encoding: .utf8)
|
||||
print("MusicXML written → \\(xmlURL.path)")
|
||||
} catch {
|
||||
fputs("MusicXML export failed: \\(error)\\n", stderr)
|
||||
printError("MusicXML export failed: \\(error)\\n")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
@@ -771,21 +808,22 @@ public enum ProjectScaffolder {
|
||||
let restored = try Score.fromMusicXML(data: score.toMusicXMLData())
|
||||
print("Round-trip events: \\(score.allEvents.count) → \\(restored.allEvents.count)")
|
||||
} catch {
|
||||
fputs("MusicXML round-trip failed: \\(error)\\n", stderr)
|
||||
printError("MusicXML round-trip failed: \\(error)\\n")
|
||||
}
|
||||
|
||||
// MARK: - Render the score offline
|
||||
|
||||
let tailSeconds = 1.5
|
||||
let renderDuration = score.totalBeats * secondsPerBeat + tailSeconds
|
||||
let outputURL = outputDir.appendingPathComponent("score.caf")
|
||||
// WAV, not CAF — see the nrt template: CAF is Apple-only.
|
||||
let outputURL = outputDir.appendingPathComponent("score.wav")
|
||||
|
||||
let engine = SynthesisEngine(
|
||||
blockSize: \(scaffoldDefaultBlockSize),
|
||||
sampleRate: \(scaffoldDefaultSampleRate),
|
||||
numOutputChannels: \(scaffoldDefaultOutputChannels),
|
||||
numInputChannels: 0,
|
||||
driver: NRTDriver(outputURL: outputURL, duration: renderDuration)
|
||||
driver: NRTDriver(outputURL: outputURL, duration: renderDuration, format: .wavFloat32)
|
||||
)
|
||||
|
||||
// Schedule one voice per sounding event BEFORE start() — NRTDriver
|
||||
@@ -805,7 +843,7 @@ public enum ProjectScaffolder {
|
||||
try engine.schedule(voice, after: event.beat * secondsPerBeat)
|
||||
scheduled += 1
|
||||
} catch {
|
||||
fputs("engine.schedule failed: \\(error)\\n", stderr)
|
||||
printError("engine.schedule failed: \\(error)\\n")
|
||||
}
|
||||
}
|
||||
print("Scheduled \\(scheduled) voices.")
|
||||
@@ -814,7 +852,7 @@ public enum ProjectScaffolder {
|
||||
try engine.start()
|
||||
print("Rendered \\(renderDuration)s → \\(outputURL.path)")
|
||||
} catch {
|
||||
fputs("Render failed: \\(error)\\n", stderr)
|
||||
printError("Render failed: \\(error)\\n")
|
||||
exit(1)
|
||||
}
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user