@kawaijs/audio
v1.0.0
Published
Multi-channel HTMLAudio music, SFX, and voice management for Kawaijs visual novels
Maintainers
Readme
@kawaijs/audio
Web Audio API sound, background music crossfading, and voice playback controller for Kawaijs visual novels.
Part of the Kawaijs visual novel engine.
Installation
npm install @kawaijs/audioFeatures
- BGM Channel: Smooth fade-in/fade-out crossfading and looping. Music requested before a user gesture is queued until unlock (no orphaned
Audioelements). - SFX Sound Pool: Concurrent sound effect playback with a bounded pool; volume changes apply to active SFX.
- Voice Lines: Dialogue voice line triggers with auto-stop on new dialogue; ducking respects the current music volume slider.
- StoryVM Integration:
audioManager.attachToVM(vm)binds scriptplay/stopcommands. Idempotent — re-attaching (or pairing withDOMRenderer, which also usesattachToVM) replaces the previous subscription instead of stacking listeners.
import { AudioManager } from '@kawaijs/audio';
import { StoryVM } from '@kawaijs/runtime';
const audio = new AudioManager();
const detach = audio.attachToVM(vm, (track) => `assets/audio/${track}`);
// … later
detach();
audio.destroy();License
MIT © Biagio Scaglia
