SPB Git

Repository Public

0004-real-time-engine.md 2.1 KB 35 lines markdown

1<!--2ORIX Sonata3File: Documentation/adr/0004-real-time-engine.md4Author: Simon-Pierre Boucher5Contact: contact@spboucher.ai6-->7# ADR 0004 — Real-time engine rules89Status: accepted (2026-11-24).1011- **One processor, two clocks.** Real-time playback and offline rendering run the same12  `Processor`; it renders in chunks of at most 64 frames cut on its own grid and at every note and13  automation boundary, so the result does not depend on the host's block size. Tests check that14  renders with blocks of 32 to 1024 frames and one giant block are bit-identical.15- **Nothing blocking in `process`.** No allocation, lock, file, network, log or compilation.16  Everything a program needs is allocated by `PreparedProgram::prepare` off the audio thread.17  Tests run the processor under a counting allocator (zero allocations over 1500 callbacks with18  commands and hot swaps).19- **Control by queues and atomics.** Transport, mixer, notes and program swaps go through a20  single-producer single-consumer ring; meters, position and scope rings are atomics read21  wait-free by the UI. Retired programs come back through a second ring and are freed off the22  audio thread.23- **Hot swap.** A new program replaces the current one at a chunk boundary with a 30 ms24  equal-power crossfade; position and live mixer settings are kept; notes sounding at the25  position are restarted in the new program. A compilation that fails changes nothing.26- **Safety.** Non-finite output of a component is replaced by silence and counted; the master27  has a look-ahead limiter (sample peak) on by default at −1 dBFS; the device output is clamped28  to ±1; the monitor level starts at −6 dB and is never part of a render; a panic in the engine29  turns the output to silence instead of noise.30- **Pan law.** Constant power, −3.01 dB at centre, on tracks and buses; no pan on the master.31- **Timing.** Musical time is exact rationals; seconds come from the tempo map; samples are32  `floor(seconds × rate + 0.5)` in one function used by every component.33- **Single audio thread** in this version. Not using the other cores is a known limit, measured34  in `Benchmarks/`.35
Files main
Menu

Theme