Skip to content

Algorithmic composition engine

sound-studies

Independent composer threads send notes over channels to a real-time synthesis engine.

// Two voices, cycling pitches across threads
let p1 = *p_iter.next().unwrap() as u8 + ((idx % 2) * 7) as u8;
let p2 = *p_iter_2.next().unwrap() as u8 + ((idx % 2) * 7) as u8;
tx.send(NoteOn(p1)).unwrap();
tx.send(NoteOn(p2)).unwrap();
let now = Instant::now();
while now.elapsed() < Duration::from_secs_f32(d1) {}
tx.send(NoteOff(p1));
tx.send(NoteOff(p2));
// → synth (BitSet phases) → cpal output

An experimental, multi-threaded algorithmic composition engine. Each composer runs on its own thread and emits NoteOn / NoteOff messages over MPSC channels to a central synthesis engine, which renders audio in real time through the system's audio device with cpal.

It's where DSCH started: the compiler was the compiler crate in this workspace before it was spun out.