
Leyline
A realtime audio graph with delay compensation, and a compiler from an edit model to a graph.
Leyline is the component that routes and processes audio through a graph of nodes in realtime. It is part of Signals & Sorcery, a coherent set of Rust audio building blocks for audio apps, plugins, players and DAWs.
| Repository | github.com/shiehn/leyline-audio-graph |
|---|---|
| License | MIT, free for commercial and closed-source use |
| Status | Planned |
| Layer | Signal flow (how the layers stack) |
| Crates (planned names) | leyline |
What it is
A graph describes nodes (a sampler, a plugin chain, a fader, a bus) and the connections between them. Leyline turns that description into something the audio thread can run every block, then keeps it running while the description changes.
- Compile. A description becomes a schedule: nodes in an order that respects every connection, buffers assigned to slots so memory is reused, and parallel levels where nodes don't depend on each other.
- Plugin delay compensation. Each node reports its latency, and Leyline adds the delays that keep every path to a mixing point aligned.
- Incremental recompile. Nodes are matched by a stable identity you give them, so a reverb's tail, a compressor's envelope or a sampler's voices survive a change.
- Lock-free publish. The new schedule reaches the audio thread through a mailbox and is swapped in at a block boundary. The old one is retired on a control thread.
- Parameter commands travel on a ring and land at a sample offset.
- One code path for live and offline, so a bounce matches what you heard.
- The edit-model compiler. A separate, swappable, pure function turns a mixer description (channels, folders, sends, plugin chains) into a graph description. Leyline defines that description, so Tapestry or any other model can produce one.
Usage example
Illustrative sketch
Planned, not final. Taken from the README.
use leyline::{GraphDesc, Node, NodeId, PrepareCfg, ProcessIo, BlockCtx};
// A custom node: prepared on a control thread, processed on the audio thread.
struct Tremolo { phase: f32, rate: f32 }
impl Node for Tremolo {
fn prepare(&mut self, cfg: &PrepareCfg) { /* may allocate here */ }
fn latency(&self) -> u32 { 0 }
fn process(&mut self, io: &mut ProcessIo<'_>, ctx: &BlockCtx) {
// audio thread: no allocation, no lock, no system call
}
}
let mut desc = GraphDesc::new();
let player = desc.add(NodeId::from("track-1/player"), sampler_node);
let trem = desc.add(NodeId::from("track-1/tremolo"), Box::new(Tremolo::new()));
desc.connect(player, trem);
desc.connect(trem, desc.output());
let mut graph = leyline::Graph::new(48_000.0, 256);
graph.publish(&desc)?; // compile, diff against the running schedule, hand it over
// Later, offline, with the same description:
let wav = graph.render_offline(&desc, 0..total_frames)?;
How it fits in the ecosystem
Leyline is the signal flow row. Dependencies point down, never up.
Below it: its core depends only on the floor: Runecraft (repo) for the handoffs and arena, and Orrery (repo) for transports. Its built-in mixer nodes wrap Cantrips (repo), and an optional adapter turns a Summoner (repo) chain into a plugin node, so the graph's own code names neither. It runs inside a device callback such as Aethergate's (repo).
Above it:
- Procession (repo) feeds it what plays.
- Tapestry (repo) produces the mixer description its compiler reads.
- Grimoire (repo) owns its life.
- Familiar processors are written against its
Nodetrait.
What it deliberately doesn't do: no tracks or clips (those are Tapestry's, and the compiler between them is replaceable), no scheduling of musical events (Procession's job), no devices, and no large DSP library (fundsp, dasp and others are welcome as custom nodes).
| Component | Repository | Role | Status |
|---|---|---|---|
| Runecraft | runecraft-audio-core | Shared contracts, realtime safety, process isolation and realtime-safe logging: the floor every other component stands on | In preparation |
| Orrery | orrery-musical-time | Tempo and meter, transports, bar, beat and sample maths, timed MIDI | In preparation |
| Summoner | summoner-plugin-host | Out-of-process VST3 and Audio Unit plugin hosting with crash isolation | In preparation |
| Aethergate | aethergate-audio-platform | Audio devices (cpal, CoreAudio, a fake device for tests) and shared-memory meters | Planned |
| Leyline | leyline-audio-graph | A realtime audio graph with delay compensation, and a compiler from an edit model to a graph | Planned |
| Cantrips | cantrips-audio-dsp | Built-in mixer DSP: sampler, fader, pan, meters, compressor | Planned |
| Scriptorium | scriptorium-audio-media | Decode and encode, a sample store, streaming voices, crash-safe recording | Planned |
| Tapestry | tapestry-session-model | Tracks, clips, lanes and scenes; edits with undo; a crash-safe project store | Planned |
| Procession | procession-timeline-engine | What plays in each block: regions, notes, automation, launches | Planned |
| Grimoire | grimoire-daw-engine | The assembled engine and its headless JSON-RPC protocol | Planned |
| Familiar | familiar-plugin-sdk | An SDK for plugins and panels that extend a Signals & Sorcery engine | Planned |
| Glyphwork | glyphwork-audio-ui | Audio UI widgets: meters, knobs, faders, waveforms | Planned |
Status
Planned. No code yet. The repository holds the design.
Target platforms: macOS, Windows and Linux. Running a graph inside a Web Audio worklet through WebAssembly is a later exploration.
Links
- Repository: github.com/shiehn/leyline-audio-graph (README, LICENSE)
- Depends on: runecraft-audio-core, orrery-musical-time; wraps cantrips-audio-dsp and, through an adapter, summoner-plugin-host
- Used by: procession-timeline-engine, grimoire-daw-engine, familiar-plugin-sdk
- All twelve components · For agents · llms.txt