Initial commit of a toy analogue audio generator

Key components:
- no_std core so it can be used bare metal on embedded systems
- default implementation for RPi 2350, with midi input and I2s output using PIO
- Visualiser for the web to play with on a dev system
This commit is contained in:
2026-03-23 15:06:31 +00:00
commit 496b6bdc71
34 changed files with 3662 additions and 0 deletions

72
www/bootstrap.js vendored Normal file
View File

@@ -0,0 +1,72 @@
/**
* bootstrap.js — ES module entry point.
*
* Imports the wasm-pack-generated glue, initialises the WASM binary, then
* wires up Rust-exported types to the canvas elements in index.html.
*/
import init, {
AudioEngine,
OscilloscopeView,
SpectrumView,
PatchBay,
SynthParams,
} from "./pkg/synth_visualiser.js";
const loader = document.getElementById("loader");
const status = document.getElementById("status");
const srLabel = document.getElementById("sample-rate");
const frameTime = document.getElementById("frame-time");
async function bootstrap() {
try {
await init();
const engine = new AudioEngine();
await engine.attach();
const analyser = engine.analyser_node();
const oscilloscope = new OscilloscopeView("oscilloscope-canvas", analyser);
const spectrum = new SpectrumView("spectrum-canvas", analyser);
const patchbay = new PatchBay("patchbay-canvas");
// Register module jacks (x, y coordinates relative to the canvas)
patchbay.register_jack("vco", "out", 50, 60, true);
patchbay.register_jack("filter", "in", 150, 60, false);
patchbay.register_jack("filter", "out", 250, 60, true);
patchbay.register_jack("vca", "in", 350, 60, false);
patchbay.register_jack("lfo", "cv-out", 450, 60, true);
patchbay.register_jack("filter", "cv-in", 550, 60, false);
const pbCanvas = document.getElementById("patchbay-canvas");
pbCanvas.addEventListener("pointerdown", e => patchbay.on_pointer_down(e.offsetX, e.offsetY));
pbCanvas.addEventListener("pointermove", e => patchbay.on_pointer_move(e.offsetX, e.offsetY));
pbCanvas.addEventListener("pointerup", e => patchbay.on_pointer_up(e.offsetX, e.offsetY));
const params = new SynthParams();
engine.set_params(params.to_json());
srLabel.textContent = `SR: ${engine.sample_rate()} Hz`;
status.textContent = "Running";
engine.start();
let last = performance.now();
function frame(now) {
oscilloscope.draw();
spectrum.draw();
patchbay.draw();
frameTime.textContent = `frame: ${(now - last).toFixed(1)} ms`;
last = now;
requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
loader.classList.add("hidden");
} catch (err) {
console.error("[bootstrap] Fatal:", err);
loader.textContent = `Error: ${err.message ?? err}`;
}
}
bootstrap();