-
Notifications
You must be signed in to change notification settings - Fork 0
Modular Bun Audio Library Outline
Cameron Brooks edited this page May 30, 2025
·
1 revision
This document expands on the technical approach for building a Bun‑native audio library inspired by AudioNodes. The goal is to keep the codebase lightweight while still allowing dynamic routing and real‑time control of short loops.
-
TypeScript Classes wrap Web Audio nodes. Examples include:
-
SamplerNodefor buffered playback and seamless looping. -
GainNodeWrapperfor volume automation. -
FilterNodeWrapperfor tone shaping.
-
- Each wrapper exposes a
.connect()method so instances can be chained just like the nativeAudioNodegraph. - The code lives in
frontend/audio/modularNodes.tsand is compiled with Bun for the browser bundle.
- The
detectLoopfunction performs a simple cross‑correlation on anAudioBufferto find a smooth end point. -
applyCrossfadefades the start and end of a clip so loops are gapless. - These utilities work hand‑in‑hand with the existing
librosa_encoder.pyscript, which trims and normalizes incoming audio files on the server.
-
bindControl()lets DOM elements modify anyAudioParam. For example, moving the mouse over a slider can change filter cutoff or sampler playback rate. - This keeps the API flexible without requiring a heavy UI framework.
- Store each user's node graph as JSON for easy reloading and sharing.
- Add wrappers for additional effects (compressor, panner) as needed.
- Explore compiling DSP‑heavy functions to WebAssembly for extra speed.
By combining Bun's fast TypeScript tooling with small Web Audio wrappers, we can deliver a responsive, modular interface that echoes AudioNodes' workflow without the overhead.