@magmacrunch/adenosine-audio
v0.2.4
Published
Web Audio API engine for game music and sound effects
Maintainers
Readme
@magmacrunch/adenosine-audio
Web Audio engine for looping game music and pooled sound effects — fades, muting, and pausing with tab visibility. No runtime dependencies.
npm install @magmacrunch/adenosine-audioUse
import * as AdAudio from '@magmacrunch/adenosine-audio';
await AdAudio.init({
music: { url: 'audio/theme.ogg', volume: 0.4, fadeIn: 2.0 },
sfx: {
deal: { url: 'audio/deal.wav', volume: 0.8, pool: 4 },
win: { url: 'audio/win.wav' },
},
});
// Browsers require a user gesture before audio may start.
playButton.addEventListener('click', () => AdAudio.playMusic());
AdAudio.playSfx('deal');
AdAudio.toggleMusicMute();
AdAudio.handleVisibility(true); // pause music while the tab is hiddenpool pre-allocates buffer sources so a rapidly repeated effect does not cut
itself off.
Without a bundler
Straight from a CDN — no npm, no build step:
<script src="https://cdn.jsdelivr.net/npm/@magmacrunch/[email protected]/dist/index.global.js"></script>The IIFE build exposes window.AdAudio. The version is pinned to a minor here on purpose:
an unpinned URL follows latest and will cross a major without warning.
Installed from npm instead, the same file is dist/index.global.js.
Full API
API.md documents every export, with parameters and return shapes.
Module format
ESM only. The exports map declares no require condition, so this cannot be
require()d from CommonJS — use import, or the IIFE build above.
License
Apache-2.0 — Copyright 2026 Magma Crunch Media.
Part of adenosine, a collection
of lightweight web game engines by magmacrunch media.
Keep the NOTICE file with any copy you distribute.
