
Scriptorium
Decode and encode, a sample store, streaming voices, crash-safe recording.
Scriptorium is the component that gets audio from files into an engine and from an engine back onto disk. 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/scriptorium-audio-media |
|---|---|
| License | MIT, free for commercial and closed-source use |
| Status | Planned |
| Layer | Sound and devices (how the layers stack) |
| Crates (planned names) | scriptorium |
What it is
Media answers one question: "give me this range of this source, in time". Scriptorium answers it for files of any size, under a memory budget, without the audio thread ever touching the disk.
- Codecs. A
Codectrait. Built in: a small, dependency-free, fuzzed WAV, RF64 and AIFF decoder and a WAV and RF64 encoder (16-bit, 24-bit and 32-bit float). Optional adapters for symphonia (more formats) and rubato (sample-rate conversion). - A resident sample store. Short samples are decoded once and shared between every voice that plays them, under a memory budget with clear eviction rules.
- Streaming voices. Long files are read ahead on a background thread into a ring a realtime voice reads from. A seek is a request, not a wait. An underrun is reported, never hidden.
- Waveform peaks at several zoom levels, computed off the audio thread.
- Crash-safe recording. A take writer streams input to disk from a non-realtime thread, with a sidecar journal. After a crash, the take is recovered up to the last journal point and its header fixed. Large takes become RF64 automatically.
- Missing media reports with a reason, so an application can show it or offer to relink.
Usage example
Illustrative sketch
Planned, not final. Taken from the README.
use scriptorium::{SampleStore, StoreBudget, Stream, TakeWriter, TakeFormat};
// Load short samples into a shared store.
let store = SampleStore::new(StoreBudget::megabytes(512));
let kick = store.load("samples/kick.wav")?; // decoded once, shared
// Stream a long file into a realtime voice.
let (mut feeder, mut voice) = Stream::open("stems/vocals.wav", 48_000.0)?;
std::thread::spawn(move || feeder.run()); // reads ahead off the audio thread
// audio thread: voice.read(&mut out) never blocks; a miss is counted and reported
// Record a take.
let mut take = TakeWriter::create("takes/take-01.wav", TakeFormat::f32(2, 48_000))?;
take.write_from(&capture_ring)?; // on a writer thread
take.finish()?;
// After a crash:
let recovered = scriptorium::recover("takes/take-01.wav")?;
How it fits in the ecosystem
Scriptorium is in the sound and devices row. Dependencies point down, never up.
Below it: Runecraft (repo) for rings and thread rules.
Above it:
- Leyline (repo)'s players read its voices.
- Procession (repo) decides when a region plays and asks for that range.
- Tapestry (repo) refers to media by content.
- Grimoire (repo) runs recording and bounces through it.
- Glyphwork waveform views draw its peaks.
What it deliberately doesn't do: no scheduling, no device input (capturing from hardware is Aethergate's job; Scriptorium writes what it is given), no competing codecs beyond the small built-in formats, and no time-stretch of its own.
| 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. A WebAssembly build that decodes into Web Audio buffers is a later exploration.