MoonBit DSP audio engine
Dependencies
moon check && moon test # type-check + run the full test suite
moon build --target wasm-gc # build for browser
moon run cmd/main # run CLI entry point///|
fn[T : FilterSym] exit_deliverable() -> T {
let lfo = T::oscillator(T::constant(2.0), Waveform::Sine)
let freq = range(lfo, 200.0, 400.0)
let carrier = T::oscillator(freq, Waveform::Sine)
let filtered = T::biquad(carrier, BiquadMode::LowPass, 800.0, 1.0)
T::output(T::gain(filtered, 0.3))
}// C major triad played twice per cycle
sequence([note_name("c3"), note_name("e3"), note_name("g3")]).fast(Rational::from_int(2))Pattern Engine DSP Engine
Pat.query(arc) CompiledDsp.process(ctx, buf)
| |
v v
Array[Event[ControlMap]] BoundVoicePool.process(ctx, L, R)
| ^
+-- { note: 60, cutoff: 800 } -----+
PatternScheduler.process_block./ Library public API facade (`moondsp.mbt` re-exports from dsp/, graph/, voice/, identity/)
dsp/ DSP primitives, tagless algebra, pan math
graph/ Compiled graph runtime, topology editing, hot-swap, control binding
voice/ Polyphonic voice pool with priority stealing
identity/ Stable ID wrappers and revision tokens for incremental editing
pattern/ Pattern engine: rational time, combinators, control maps, authoring docs
mini/ Mini-notation parser: text → Pat[ControlMap]
song/ Long-form section scaffold with identity TimeScope
scheduler/ Pattern scheduler: bridges pattern events to voice pool
browser/ AudioWorklet integration (wasm-gc/js exports)
browser_test/ Browser-integration test wrapper
web/ Browser demo UI (HTML + AudioWorklet processor)
cmd/main/ CLI entry point
docs/ Architecture blueprint, technical reference, performance snapshotsmoon check # type-check
moon test # run the full test suite
moon test -p dowdiness/moondsp # run integration tests against the facade (root package only)
moon test -p pattern # run pattern-engine tests only
moon info && moon fmt # regenerate interfaces + format (run before committing)
moon bench --release -p graph -f graph_benchmark.mbt # run performance benchmarks
npm run test:browser # Playwright browser-integration tests (builds wasm-gc first)| Phase | Status | Summary |
|---|---|---|
| 0 — Platform proof | Complete | MoonBit wasm-gc runs in browser AudioWorklet |
| 1 — DSP primitives | Complete | Oscillators, filters, envelopes, delay, gain, mix, clip, pan |
| 2 — Graph compiler | Complete | Compiled graphs, hot-swap, topology editing, stereo |
| 3 — Voice management | Complete | 32+ voice pool with priority stealing and stereo mixdown |
| 4 — Pattern engine | Complete | Rational time, 8 combinators, ControlMap output |
| 5 — Pattern × DSP | Complete | scheduler/ + mini/ wire pattern events to voice allocation |
| 6 — incr integration | In progress | Stable identity plus initial pattern/song authoring groundwork |
| 7+ — UI, native, collab | Planned | REPL, CLAP plugins, CRDT multi-user |
fn is_finite(value : Double) -> Boolfn is_finite_positive(value : Double) -> Boolfn[T : ArithSym] lin_map(input : T, in_lo : Double, in_hi : Double, out_lo : Double, out_hi : Double) -> Tfn pan_left_gain(position : Double) -> Doublefn pan_right_gain(position : Double) -> Doublefn[T : ArithSym + DspSym + FilterSym + DelaySym + StereoSym + StereoFilterSym + StereoDelaySym] replay(nodes : Array[DspNode]) -> T?fn stereo_shape() -> IntMoonBit DSP audio engine
Dependencies