b6fdee8bfc
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>
283 lines
10 KiB
Markdown
283 lines
10 KiB
Markdown
# Lyrebird on Linux
|
|
|
|
Lyrebird is a native audio-synthesis framework in Swift. You implement `Generator`
|
|
and `Synthesizer` types; the engine handles audio I/O and signal-graph evaluation.
|
|
As of **2.0**, Lyrebird runs on Linux with full parity across the engine, the
|
|
standard generator library, offline render, live audio (ALSA), MIDI, OSC, the
|
|
GTK4 GUI, and the live-coding scratchpad.
|
|
|
|
This is the Linux guide: install, build, run, scaffold a project, and the feature
|
|
map. For the macOS/iOS story and the framework internals, see the top-level docs.
|
|
|
|
---
|
|
|
|
## 1. Requirements
|
|
|
|
**Distribution.** Ubuntu 24.04 LTS is the tested target — it matches the CI image
|
|
(`swift:6.3.3`). Other modern glibc distributions work but are untested. (An ARM64
|
|
Ubuntu VM — e.g. Parallels on Apple silicon — is a supported dev setup.)
|
|
|
|
**Swift toolchain.** Use the **swift.org** toolchain (6.0+), *not* a distro
|
|
package. [swiftly](https://www.swift.org/install/linux/) is the easiest installer:
|
|
|
|
```bash
|
|
curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz
|
|
tar zxf swiftly-$(uname -m).tar.gz && ./swiftly init
|
|
# in a new shell:
|
|
swiftly install latest
|
|
swift --version
|
|
```
|
|
|
|
If a new shell can't find `swift`/`swiftc`/`sourcekit-lsp`, add swiftly's bin
|
|
directory to `PATH` (Lyrebird's tools search `PATH`, so this is all that's needed):
|
|
|
|
```bash
|
|
echo 'export PATH="$HOME/.local/share/swiftly/bin:$PATH"' >> ~/.bashrc
|
|
source ~/.bashrc
|
|
```
|
|
|
|
**System packages.** Install what you need for the features you want:
|
|
|
|
```bash
|
|
# Build/link the core + tests:
|
|
sudo apt install build-essential pkg-config
|
|
|
|
# Live audio + MIDI (ALSA backends). Without this, build with
|
|
# LYREBIRD_DISABLE_ALSA=1 — everything compiles, but there is no sound or MIDI:
|
|
sudo apt install libasound2-dev
|
|
|
|
# The GTK4 GUI and the live-coding scratchpad:
|
|
sudo apt install libgtk-4-dev libgtksourceview-5-dev libfontconfig-dev
|
|
```
|
|
|
|
**IDE.** There is no Xcode on Linux. The maintained path is **VS Code + the
|
|
official Swift extension** (`swiftlang.swift-vscode`) — SourceKit-LSP completion,
|
|
diagnostics, LLDB debugging, and a test explorer:
|
|
|
|
```bash
|
|
code --install-extension swiftlang.swift-vscode
|
|
```
|
|
|
|
Open the repository folder; the extension reads `Package.swift` automatically.
|
|
Neovim/Emacs with `sourcekit-lsp` also work.
|
|
|
|
---
|
|
|
|
## 2. Build and test
|
|
|
|
```bash
|
|
git clone git@bitbucket.org:realizedsound/lyrebird.git
|
|
cd lyrebird
|
|
swift build
|
|
swift test --no-parallel # --no-parallel avoids a known parallel-runner teardown flake
|
|
```
|
|
|
|
On a Linux host the manifest omits the Apple-only targets, so `swift build` /
|
|
`swift test` compile the portable surface: the core engine + generators
|
|
(`LyrebirdSynth`), the interpreted graph DSL (`LyrebirdGraphDSL`), the CLI
|
|
(`LyrebirdCLI`), the GTK4 UI (`LyrebirdUI` + backend), and the Linux demos.
|
|
|
|
No sound stack on the box? Build and test everything except the ALSA driver:
|
|
|
|
```bash
|
|
LYREBIRD_DISABLE_ALSA=1 swift test --no-parallel
|
|
```
|
|
|
|
The **LiveCompile** live-coding subsystem is a separate SwiftPM package under
|
|
`LiveCompile/` (it dynamically links the engine, so it builds on its own):
|
|
|
|
```bash
|
|
cd LiveCompile
|
|
swift build
|
|
swift test --no-parallel
|
|
```
|
|
|
|
---
|
|
|
|
## 3. Set up a project
|
|
|
|
Scaffold a new Swift package wired to Lyrebird with the CLI:
|
|
|
|
```bash
|
|
swift run LyrebirdCLI new MyProject --template quickstart
|
|
cd MyProject
|
|
swift run
|
|
```
|
|
|
|
Templates:
|
|
|
|
| `--template` | What you get |
|
|
|---|---|
|
|
| `quickstart` | Fastest sound — a 440 Hz sine to the speakers. |
|
|
| `basic` | Default starter synth + engine setup. |
|
|
| `demo` | A richer multi-generator example. |
|
|
| `nrt` | Offline render to a WAV (`output.wav`) — no audio device needed. |
|
|
| `score` | Render from notation (MusicXML in, WAV out). |
|
|
| `ui-demo` | A GUI scaffold (AppKit on macOS; see the GTK4 demos below on Linux). |
|
|
|
|
The generated project calls `makeDefaultAudioDriver()`, which resolves to
|
|
`ALSAAudioDriver` on Linux (or a silent `OfflineDriver` when there is no live
|
|
backend — check `isLiveAudioAvailable`). Never name a concrete driver directly in
|
|
portable code; `makeDefaultAudioDriver()` picks the right one for how the package
|
|
was built.
|
|
|
|
---
|
|
|
|
## 4. Run the built-in samples
|
|
|
|
### Offline render — works with no audio device
|
|
|
|
The surest first run. Renders a WAV end-to-end, no hardware involved:
|
|
|
|
```bash
|
|
swift run LyrebirdCLI new MyRender --template nrt
|
|
cd MyRender && swift run # writes output.wav
|
|
```
|
|
|
|
### Live audio — needs a working sound device
|
|
|
|
In a VM, make sure the guest has audio (`aplay -l` should list a device):
|
|
|
|
```bash
|
|
swift run LyrebirdCLI new MyTone --template quickstart
|
|
cd MyTone && swift run # a sine tone for a few seconds
|
|
```
|
|
|
|
### REPL
|
|
|
|
```bash
|
|
swift run LyrebirdCLI repl
|
|
```
|
|
|
|
Drops into a Swift REPL with `import LyrebirdSynth` wired up — define generators
|
|
and synthesizers and add them to a running engine live.
|
|
|
|
### GTK4 GUI demo
|
|
|
|
A live parameter-control window (needs `libgtk-4-dev` + a display; sound needs
|
|
`libasound2-dev` + a device):
|
|
|
|
```bash
|
|
swift run LyrebirdUILinuxDemo
|
|
```
|
|
|
|
The default window shows live CPU-load meters, a live oscilloscope of the stereo
|
|
output, an example envelope plot, and controls for two parameters (frequency and
|
|
amplitude): an XY pad, a knob, a slider, and a readout each, plus a gate toggle
|
|
and reset. Every control bound to a parameter observes the same `@UIParam` node,
|
|
so moving one (say the freq knob) updates the others live — the same parameter
|
|
model the macOS SwiftUI controls use.
|
|
|
|
Pick a focused demo with `LYREBIRD_DEMO`:
|
|
|
|
| `LYREBIRD_DEMO` | Demo |
|
|
|---|---|
|
|
| `full` (default) | The full control panel described above. |
|
|
| `knob` | A single knob driving a sine tone. |
|
|
| `mouse` | `Mouse.X` / `Mouse.Y` / `Mouse.Click` driving synthesis from pointer position. |
|
|
| `events` | The process / event-list performance views. |
|
|
| `narrowtest` | A narrow-path redraw isolation harness (development aid). |
|
|
|
|
```bash
|
|
LYREBIRD_DEMO=mouse swift run LyrebirdUILinuxDemo
|
|
```
|
|
|
|
### Live-coding scratchpad
|
|
|
|
A GTK4 window with a real code editor that compiles and runs Swift snippets into
|
|
the live engine — Lyrebird's answer to a live-coding environment. It lives in the
|
|
`LiveCompile` package and needs `libgtksourceview-5-dev`:
|
|
|
|
```bash
|
|
cd LiveCompile
|
|
swift build # build first: the snippet links the engine's dynamic libs
|
|
swift run LyrebirdScratchLinuxDemo
|
|
```
|
|
|
|
> The `swift build` step is required before `swift run`: a snippet links against
|
|
> `libLyrebirdDynamic` / `libLyrebirdLiveCompileDynamic`, which `swift build`
|
|
> produces but `swift run` alone does not.
|
|
|
|
Type Swift, evaluate, hear it. `context` is your live session:
|
|
|
|
```swift
|
|
context.play { OscSin.Audio(freq: 330, mul: 0.15) }
|
|
context.reportMessage("playing 330 Hz")
|
|
```
|
|
|
|
Scratchpad features:
|
|
|
|
- **Swift editor** — GtkSourceView with syntax highlighting, a line-number gutter,
|
|
and auto-indent.
|
|
- **Code completion** — `Ctrl+Space` at the caret shows sourcekit-lsp completions
|
|
(types, members, parameters), filtered by what you've typed.
|
|
- **Run (fresh)** — clears the previous snippet's synths and runs the buffer.
|
|
- **Run (additive)** — layers the new snippet on top of what's already playing.
|
|
- **Line evaluation** — select one or more lines and Run evaluates just those.
|
|
- **Stop audio** — a panic button that clears all snippet audio without tearing
|
|
down the engine.
|
|
- **Live oscilloscope** — shows the session's stereo output in real time.
|
|
- **Save / load** — a File menu (`New`, `Open…`, `Save`, `Save As…`) with
|
|
`Ctrl+N` / `Ctrl+O` / `Ctrl+S` / `Ctrl+Shift+S` accelerators and native file
|
|
dialogs. Snippets are plain `.swift` files; the title shows a `●` when there are
|
|
unsaved edits.
|
|
|
|
---
|
|
|
|
## 5. Feature map
|
|
|
|
| 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 | ✅ | ALSA; needs `libasound2-dev` + a device |
|
|
| MIDI in/out | ✅ | ALSA sequencer |
|
|
| OSC | ✅ | POSIX UDP |
|
|
| GTK4 GUI (`LyrebirdUI`) | ✅ | knob / slider / label / button / XY pad + scope + envelope + CPU status; standalone windows; mouse input; on the [SwiftOpenUI](https://github.com/joshpar/SwiftOpenUI) GTK4 backend |
|
|
| Live-coding scratchpad | ✅ | `LiveCompile`; editor + completion + save/load + live scope |
|
|
| SwiftUI UI | ❌ | macOS/iOS only (Lyrebird uses GTK4 on Linux) |
|
|
| AUv3 plugin | ❌ | Apple-only |
|
|
|
|
The GTK4 UI builds on a pinned release of the
|
|
[joshpar/SwiftOpenUI](https://github.com/joshpar/SwiftOpenUI) fork (see
|
|
`Package.swift`). To develop against a local checkout of the fork, point
|
|
`LYREBIRD_SWIFTOPENUI_LOCAL` at it:
|
|
|
|
```bash
|
|
LYREBIRD_SWIFTOPENUI_LOCAL=/path/to/SwiftOpenUI swift build
|
|
```
|
|
|
|
---
|
|
|
|
## 6. Troubleshooting
|
|
|
|
- **No sound / `isLiveAudioAvailable` is false.** Confirm ALSA sees a device with
|
|
`aplay -l`. In a VM, enable guest audio. To work without any sound stack, build
|
|
with `LYREBIRD_DISABLE_ALSA=1`.
|
|
- **`swiftc` / `sourcekit-lsp` not found** (common with swiftly). Add
|
|
`~/.local/share/swiftly/bin` to `PATH` (see §1). Lyrebird searches `PATH`, so
|
|
no further configuration is needed.
|
|
- **`gtk/gtk.h` or `gtksourceview/gtksource.h` not found.** Install the dev
|
|
packages: `libgtk-4-dev`, `libgtksourceview-5-dev`, `libfontconfig-dev`.
|
|
- **Scratchpad snippet fails to link** (`cannot find -lLyrebirdLiveCompileDynamic`).
|
|
Run `swift build` in `LiveCompile/` before `swift run` (see §4).
|
|
- **`Package.resolved` shows up as modified after a Linux build.** The Linux
|
|
dependency resolve records the SwiftOpenUI pin; run `git checkout Package.resolved`
|
|
before committing to keep the tree clean.
|
|
|
|
---
|
|
|
|
## 7. Reference
|
|
|
|
- `docs/linux-getting-started.md` — the original getting-started walkthrough.
|
|
- `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.
|
|
- `Sources/Lyrebird/MIDI/ALSAMIDI.swift`, `Sources/Lyrebird/OSC/OSCServer.swift` —
|
|
the Linux MIDI and OSC backends.
|
|
- `LiveCompile/Sources/LyrebirdLiveCompileUI/LyrebirdLiveCompileUI.docc/LiveCoding.md`
|
|
— the live-coding subsystem.
|