Scriptorium audio media illustration

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.

Repositorygithub.com/shiehn/scriptorium-audio-media
LicenseMIT, free for commercial and closed-source use
StatusPlanned
LayerSound 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 Codec trait. 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 READMEopen in new window.

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 (repoopen in new window) for rings and thread rules.

Above it:

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.

Extend and display
The engine
Musical structure
Signal flow
ComponentRepositoryRoleStatus
Runecraftrunecraft-audio-coreShared contracts, realtime safety, process isolation and realtime-safe logging: the floor every other component stands onIn preparation
Orreryorrery-musical-timeTempo and meter, transports, bar, beat and sample maths, timed MIDIIn preparation
Summonersummoner-plugin-hostOut-of-process VST3 and Audio Unit plugin hosting with crash isolationIn preparation
Aethergateaethergate-audio-platformAudio devices (cpal, CoreAudio, a fake device for tests) and shared-memory metersPlanned
Leylineleyline-audio-graphA realtime audio graph with delay compensation, and a compiler from an edit model to a graphPlanned
Cantripscantrips-audio-dspBuilt-in mixer DSP: sampler, fader, pan, meters, compressorPlanned
Scriptoriumscriptorium-audio-mediaDecode and encode, a sample store, streaming voices, crash-safe recordingPlanned
Tapestrytapestry-session-modelTracks, clips, lanes and scenes; edits with undo; a crash-safe project storePlanned
Processionprocession-timeline-engineWhat plays in each block: regions, notes, automation, launchesPlanned
Grimoiregrimoire-daw-engineThe assembled engine and its headless JSON-RPC protocolPlanned
Familiarfamiliar-plugin-sdkAn SDK for plugins and panels that extend a Signals & Sorcery enginePlanned
Glyphworkglyphwork-audio-uiAudio UI widgets: meters, knobs, faders, waveformsPlanned

Status

Planned. No code yet. The repositoryopen in new window holds the design.

Target platforms: macOS, Windows and Linux. A WebAssembly build that decodes into Web Audio buffers is a later exploration.

Last Updated:
Contributors: shiehn