$ show surikov/webaudiofont
WebAudioFont is a browser-based sample synthesis library that enables playback of SoundFont instruments (GeneralUserGS, FluidR3, etc.) via the Web Audio API. It provides a comprehensive set of classes: `WebAudioFontPlayer` for scheduling notes, chords, and strums; `WebAudioFontLoader` for dynamic loading of instrument presets from an external GitHub Pages repository; `WebAudioFontChannel` for a 10-band equalizer; `WebAudioFontReverberator` for convolution reverb with a built-in impulse response; and `WebAudioFontTicker` for requestAnimationFrame-based sequencing. The library is written in TypeScript, compiled into a single bundled file (`WebAudioFontPlayer.js`), and includes numerous interactive HTML examples (piano, drums, MIDI player, custom samples) that demonstrate real-world usage. Architecturally, the library is a monolith with well-defined modules but no formal test suite. It relies on an external data repository for instrument sound data, which is fetched as JavaScript files defining global variables. The core player uses a queue-based scheduling system with envelope reuse and zone/preset selection. The channel and reverberator classes form a modular audio graph that can be connected to the audio context destination. The library is licensed under GPL-3.0 and is actively maintained by a single developer, with recent commits and a responsive issue tracker. However, the external data dependency and lack of testing pose moderate risks for long-term stability.
The LLM identified 3 files worth highlighting for reuse:
Implements a 10-band peaking equalizer as a chain of BiquadFilterNode instances with standard frequencies (32Hzā16kHz). Provides input/output AudioNode properties and a `setGain` method for per-band adjustment. This is a self-contained, reusable audio component that can be extracted into any Web Audio project requiring a parametric equalizer, demonstrating clean audio graph construction and modular design.
Implements a convolution reverb effect using a hardcoded base64-encoded impulse response. The audio graph consists of a BiquadFilter input, a ConvolverNode, a dry/wet mixing path, and a DynamicsCompressorNode on the output. Provides `input` and `output` properties for easy integration into any audio chain. This pattern is reusable for any Web Audio application needing a reverb effect, with the impulse response replaceable for different room simulations.
Implements a time-based scheduler using `requestAnimationFrame` for smooth note sequencing. Provides a state machine with `stateStop`, `statePlay`, `stateEnd` constants, and methods `startTicks`, `playLoop`, `tick`, `cancel`. Handles loop points and callback-oriented tick events. This is a reusable scheduling pattern for any browser-based audio or animation project that requires precise timing independent of the audio clock, demonstrating clean separation of timing logic from audio playback.