v2.3.1 release: cross-platform LyrebirdGUIDemo + Linux demo ports + doc refresh
- New Demos/LyrebirdGUIDemo: one shared source (synths + node-based views) that bootstraps SwiftUI on macOS and GTK4/SwiftOpenUI on Linux; LYREBIRD_DEMO=vector|sine. - The four CLI demos (Quickstart/Demo/NRT/Score) now build and run on Linux. - README + Linux getting-started refreshed; LyrebirdATK row removed from the Extensions section pending collaborator sign-off. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,17 @@
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
/// Directory this demo writes its output files to: the Desktop on Apple (matching the
|
||||
/// Xcode scheme), the current working directory elsewhere (Linux has no Desktop folder
|
||||
/// to grant, and `swift run` starts from a known location).
|
||||
func demoOutputDirectory() -> URL {
|
||||
#if canImport(AudioToolbox)
|
||||
return FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent("Desktop")
|
||||
#else
|
||||
return URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Builds a multi-part Score using every DSL node type, exports MusicXML, round-trips
|
||||
/// the document, and reports render statistics.
|
||||
///
|
||||
@@ -58,15 +69,15 @@ final class ScoreDemo: DemoProtocol {
|
||||
/// Export MusicXML and print the round-trip event count. Does not interact with
|
||||
/// the engine or schedule any voices.
|
||||
func runDemo() {
|
||||
// Step 1 — write MusicXML to Desktop.
|
||||
let xmlURL: URL = FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent("Desktop/LyrebirdScoreDemo.musicxml")
|
||||
// Step 1 — write MusicXML to the demo output directory.
|
||||
let xmlURL: URL = demoOutputDirectory()
|
||||
.appendingPathComponent("LyrebirdScoreDemo.musicxml")
|
||||
let xmlString: String = score.toMusicXMLString()
|
||||
do {
|
||||
try xmlString.write(to: xmlURL, atomically: true, encoding: .utf8)
|
||||
print("MusicXML written → \(xmlURL.path)")
|
||||
} catch {
|
||||
fputs("Failed to write MusicXML: \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("Failed to write MusicXML: \(error)\n".utf8))
|
||||
}
|
||||
|
||||
// Step 2 — round-trip sanity check.
|
||||
@@ -105,7 +116,7 @@ final class ScoreDemo: DemoProtocol {
|
||||
print("Score key (G major): \(rt.keySignature == .gMajor ? "OK" : "MISMATCH(\(rt.keySignature))")")
|
||||
}
|
||||
} catch {
|
||||
fputs("MusicXML round-trip failed: \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("MusicXML round-trip failed: \(error)\n".utf8))
|
||||
}
|
||||
|
||||
// Step 2b — sectioned showcase: multiple Sections assembled into one
|
||||
@@ -119,8 +130,8 @@ final class ScoreDemo: DemoProtocol {
|
||||
// `rehearsalMarksAsStaffText: true` option emits boxed <words> staff text
|
||||
// instead, but that attaches to a staff and can collide with notation.
|
||||
let showcase: Score = ScoreDemo.makeSectionedShowcase()
|
||||
let showcaseURL: URL = FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent("Desktop/LyrebirdScoreSections.musicxml")
|
||||
let showcaseURL: URL = demoOutputDirectory()
|
||||
.appendingPathComponent("LyrebirdScoreSections.musicxml")
|
||||
do {
|
||||
try showcase.toMusicXMLString().write(to: showcaseURL, atomically: true, encoding: .utf8)
|
||||
print("Sectioned showcase written → \(showcaseURL.path)")
|
||||
@@ -132,7 +143,7 @@ final class ScoreDemo: DemoProtocol {
|
||||
print("Sections → rehearsal marks: \(markList)")
|
||||
print("Sectioned showcase parts: \(showcase.parts.map { $0.name }.joined(separator: ", "))")
|
||||
} catch {
|
||||
fputs("Failed to write sectioned showcase: \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("Failed to write sectioned showcase: \(error)\n".utf8))
|
||||
}
|
||||
|
||||
// Step 3 — report render parameters.
|
||||
@@ -185,7 +196,7 @@ final class ScoreDemo: DemoProtocol {
|
||||
try engine.schedule(voice, after: startSeconds)
|
||||
scheduledCount += 1
|
||||
} catch {
|
||||
fputs("engine.schedule failed for beat \(event.beat): \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("engine.schedule failed for beat \(event.beat): \(error)\n".utf8))
|
||||
failedCount += 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,16 @@
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
// Output paths — both land on the Desktop.
|
||||
let cafURL: URL = FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent("Desktop/LyrebirdScoreDemo.caf")
|
||||
// Audio output. CAF is Apple-only (ExtAudioFile), so off Apple we render the
|
||||
// portable WAV codec; `demoOutputDirectory()` is the Desktop on Apple and the
|
||||
// current working directory elsewhere (see ScoreDemo.swift).
|
||||
#if canImport(AudioToolbox)
|
||||
let outputFormat: AudioFileFormat = .cafFloat32
|
||||
let audioURL: URL = demoOutputDirectory().appendingPathComponent("LyrebirdScoreDemo.caf")
|
||||
#else
|
||||
let outputFormat: AudioFileFormat = .wavFloat32
|
||||
let audioURL: URL = demoOutputDirectory().appendingPathComponent("LyrebirdScoreDemo.wav")
|
||||
#endif
|
||||
|
||||
// Render parameters.
|
||||
let sampleRate: Double = 48000
|
||||
@@ -23,7 +30,7 @@ let totalDuration: Double = demo.totalDuration
|
||||
demo.runDemo()
|
||||
|
||||
// Create NRTDriver and engine.
|
||||
let driver: NRTDriver = NRTDriver(outputURL: cafURL, duration: totalDuration)
|
||||
let driver: NRTDriver = NRTDriver(outputURL: audioURL, duration: totalDuration, format: outputFormat)
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: blockSize,
|
||||
sampleRate: sampleRate,
|
||||
@@ -37,12 +44,12 @@ let engine: SynthesisEngine = SynthesisEngine(
|
||||
// isolated, so this is a plain direct call — no MainActor hop needed.
|
||||
demo.scheduleVoices(engine: engine)
|
||||
|
||||
print(String(format: "Rendering %.2f s → %@", totalDuration, cafURL.path))
|
||||
print(String(format: "Rendering %.2f s → %@", totalDuration, audioURL.path))
|
||||
|
||||
do {
|
||||
try engine.start()
|
||||
print("Done.")
|
||||
} catch {
|
||||
fputs("Render failed: \(error)\n", stderr)
|
||||
FileHandle.standardError.write(Data("Render failed: \(error)\n".utf8))
|
||||
exit(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user