# Lyrebird on Linux — getting started Lyrebird began as a macOS/iOS framework; a cross-platform port makes its non-UI core — the engine, generators, CLI, offline render, live ALSA audio, ALSA MIDI, and OSC — build and run on Linux. This guide gets you from a bare Ubuntu box to a built tree, a passing test suite, and a rendered sample. > **Status.** The headless surface is complete and CI-tested on x86_64. Live > audio (ALSA) and MIDI are built but their on-hardware acceptance is still being > verified — see `LINUX_PLAN.md`. The macOS SwiftUI UI (`LyrebirdUI`) is Apple-only, > but an **experimental, opt-in** GTK4 UI (`LyrebirdUILinux`, on > [SwiftOpenUI](https://github.com/codelynx/SwiftOpenUI)) builds under a flag and > ships a runnable knob demo — see [Run a sample](#4-run-a-sample). It currently > depends on a personal fork carrying an unmerged gesture fix. ## 1. Prerequisites **Distribution.** Ubuntu 24.04 LTS is the tested target — it is what the CI image (`swift:6.3.3`) and the cross-compile SDK are built against. Other modern glibc distros work but are untested. **Swift toolchain.** Use the **swift.org** toolchain (6.0 or newer), not a distro package. The easiest installer is [swiftly](https://www.swift.org/install/linux/): ```bash curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz tar zxf swiftly-$(uname -m).tar.gz && ./swiftly init # then, in a new shell: swiftly install latest swift --version ``` `swiftly init` appends its environment to `~/.bashrc`, but if a new shell can't find `swiftly` or `swift`, add its bin directory to `PATH` yourself and reload: ```bash echo 'export PATH="$HOME/.local/share/swiftly/bin:$PATH"' >> ~/.bashrc source ~/.bashrc ``` **System packages.** ```bash # Always needed to build/link the test suite: sudo apt install build-essential pkg-config # Live audio + MIDI (the ALSA backends). Without this the package still builds # with LYREBIRD_DISABLE_ALSA=1, but there is no sound or MIDI: sudo apt install libasound2-dev # Only for the GTK4 GUI spike (spikes/SwiftOpenUIKnob/): sudo apt install libgtk-4-dev ``` ## 2. IDE There is no Xcode on Linux. The maintained path is **VS Code + the official Swift extension** (`swiftlang.swift-vscode`): SourceKit-LSP autocomplete and diagnostics, LLDB debugging, a test explorer, and SwiftPM integration. ```bash code --install-extension swiftlang.swift-vscode ``` Open the repository folder; the extension picks up `Package.swift` automatically. Neovim/Emacs with `sourcekit-lsp` also work if you prefer. ## 3. Get the source and build ```bash git clone git@bitbucket.org:realizedsound/lyrebird.git cd lyrebird swift build ``` On a Linux host the package manifest omits the Apple-only targets (`LyrebirdUI`, the AudioToolbox-importing test targets, the benchmarks), so `swift build` / `swift test` compile only the portable surface — the core engine + generators (`LyrebirdSynth`), the interpreted graph DSL (`LyrebirdGraphDSL`), and the CLI. Run the tests. `--no-parallel` is the canonical command (the parallel runner has a known teardown flake): ```bash swift test --no-parallel ``` No sound stack? Build and test everything except the ALSA driver: ```bash LYREBIRD_DISABLE_ALSA=1 swift test --no-parallel ``` ## 4. Run a sample ### Offline render — works with no audio device The surest first run: scaffold a project that renders a soundfile, no hardware involved. It exercises the whole engine end to end and drops a WAV next to the sources. ```bash swift run LyrebirdCLI new MyRender --template nrt cd MyRender swift run # renders output.wav ``` The `score` template does the same from notation, writing a MusicXML file and a WAV. ### Live audio — needs a working sound device Once ALSA sees a device (in a VM, make sure the guest has audio; test with `aplay -l`), the real-time templates play to the speakers. The generated project calls `makeDefaultAudioDriver()`, which resolves to `ALSAAudioDriver` on Linux: ```bash swift run LyrebirdCLI new MyTone --template quickstart cd MyTone swift run # a 440 Hz sine for a few seconds ``` `isLiveAudioAvailable` reports `false` if the build has no live backend (e.g. built with `LYREBIRD_DISABLE_ALSA=1`), in which case `makeDefaultAudioDriver()` returns a silent `OfflineDriver`. ### REPL and live coding ```bash swift run LyrebirdCLI repl ``` builds the package and drops into a Swift REPL with `import LyrebirdSynth` wired up — define generators and synthesizers and add them to a running engine live. ### The GUI demo (experimental) An opt-in GTK4 knob demo drives a live sine tone from `LyrebirdUILinux`. It needs `libgtk-4-dev` (and `libasound2-dev` + a device for sound) and a display, and it pulls a personal fork of SwiftOpenUI carrying an unmerged gesture fix, so it is behind the `LYREBIRD_ENABLE_LINUX_UI` flag and not part of the default build: ```bash LYREBIRD_ENABLE_LINUX_UI=1 swift run LyrebirdUILinuxDemo ``` A window opens with live CPU-load meters, a live oscilloscope of the stereo output, a static plot of an example envelope, and controls for two parameters (frequency, amplitude): an XY pad driving both at once, a knob, a slider, and a value readout for each, a gate toggle, and a reset button. Drag any control; with a live ALSA device the tone tracks in real time and the scope shows the waveform. Because every control bound to a parameter observes the same `@UIParam` node, moving one (say the freq knob) updates the others (the freq slider and readout) live — the same parameter model the macOS SwiftUI controls use. > The one-time dependency resolve writes the fork pin into `Package.resolved`. > That pin is intentionally **not** committed — run `git checkout Package.resolved` > if you plan to commit, to keep the default build fork-free. The earlier, self-contained `spikes/SwiftOpenUIKnob/` (run with `cd spikes/SwiftOpenUIKnob && swift run`) remains as the isolated gesture-fix reproduction; see its README. ## What is and isn't available on Linux | Capability | Linux | Notes | |---|---|---| | Core engine + generators | ✅ | `LyrebirdSynth` | | Interpreted graph DSL | ✅ | `LyrebirdGraphDSL` | | CLI / REPL / scaffolding | ✅ | glibc; not built under musl | | Offline render (NRT → WAV) | ✅ | portable WAV codec; CAF/AIFF/AAC are Apple-only | | Soundfile load / DiskIn | ✅ | WAV only off Apple | | Live audio | ✅ built | ALSA; needs `libasound2-dev` + a device | | MIDI in/out | ✅ built | ALSA sequencer; needs a controller to verify | | OSC | ✅ | POSIX UDP; loopback-verified | | SwiftUI UI (`LyrebirdUI`) | ❌ | Apple-only | | GTK4 UI (`LyrebirdUILinux`) | ⚗️ opt-in | Experimental; `LYREBIRD_ENABLE_LINUX_UI=1`; on a SwiftOpenUI fork; knob/slider/label/button/XY + scope + envelope + CPU status ported + demo | | AUv3 plugin | ❌ | Apple-only | ## Reference - `LINUX_PLAN.md` — port status, remaining work, and how it was built. - `docs/cross-platform-feasibility.md` — the porting approach. - `docs/engine/alsa-audio-driver.md` — the Linux audio driver. - `docs/engine/portable-wav-codec.md` — the off-Apple WAV read/write path.