moont-web
WebAssembly wrapper for the moont CM-32L
synthesizer. Provides a CM32LWeb struct that hooks into the Web Audio API
via ScriptProcessorNode for real-time audio output at 32 kHz.
Usage from JavaScript
Build with wasm-bindgen --target web:
import init, { CM32LWeb } from './moont_web.js';
await init();
const synth = new CM32LWeb(); // requires bundle-rom feature
// Note On: channel 1, note C4, velocity 100.
synth.play_midi(new Uint8Array([0x90, 60, 100]));
// Note Off.
synth.play_midi(new Uint8Array([0x80, 60, 0]));
Without the bundle-rom feature, load ROMs dynamically:
const ctrl = new Uint8Array(await fetch('CM32L_CONTROL.ROM').then(r => r.arrayBuffer()));
const pcm = new Uint8Array(await fetch('CM32L_PCM.ROM').then(r => r.arrayBuffer()));
const synth = CM32LWeb.from_rom(ctrl, pcm);
Features
bundle-rom— Bundles the CM-32L ROMs into the WASM binary, enabling thenew CM32LWeb()constructor. Enablesmoont/bundle-rom.
Building
cargo build -p moont-web --target wasm32-unknown-unknown --release --features bundle-rom
wasm-bindgen --target web --out-dir pkg target/wasm32-unknown-unknown/release/moont_web.wasm
A demo/ directory and tools/run-web-demo.sh script are included in the
repository for quick local testing.
Related Crates
| Crate | Description |
|---|---|
| moont | Core CM-32L synthesizer library |
| moont-render | Render .mid files to .wav |
| moont-live | Real-time ALSA MIDI sink |
License
moont-web is distributed under LGPL 2.1+.
Copyright (C) 2021-2026 Geoff Hill geoff@geoffhill.org
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.