Bash.tv → GitHub → itch.io

Give a game separate master, music, sound effects, voice and UI volumes (or your own buses): perceptual volume curves, mute per bus, ducking so music dips under voice lines or big moments (several ducks at once, the deepest wins), smooth changes without clicks, saved settings, and sliders and checkboxes bound to a settings screen. Includes a mixer module that builds on the web audio engine. Use...

Download skill (.zip) Files on GitHub

Game audio mixer

import { createEngine } from "./engine.js";
import { createMixer } from "./mixer.js";               // assets/mixer.js (engine.js is included)
const engine = createEngine(); const mix = createMixer(engine);
engine.play("coin", { to: mix.bus("sfx") });
mix.set("music", 0.4);  mix.mute("sfx", true);
const voice = engine.play("intro-line", { to: mix.bus("voice") });
mix.duckWhile("music", voice, { to: 0.3 });
mix.bindSlider(document.querySelector("#music-volume"), "music");

Default buses: master, music, sfx, voice, ui (each feeds master). Your own: createMixer(engine, { buses: { master: null, music: "master", world: "master", ambience: "world" } }).

Settings screen

Sliders 0 to 1 for master, music and effects, plus a mute checkbox. Changes apply at once and save (localStorage, key game-mixer). game-settings-system has the menu; bind its controls with bindSlider. A mute key (M) helps too.

Ducking

Duck music under voice lines, cutscenes, pause menus (to about 0.3) and big hits (short, to 0.6). Ducks stack: the deepest active one wins, and releasing all returns to full.

Levels to start from

Master 0.9, music 0.6, sfx 0.8, voice 0.9, ui 0.7. Then listen on phone speakers and headphones: effects that matter for play (a warning, a hit) must be heard over music.

Pitfalls

One volume for everything, setting gain directly (clicks), music that never ducks under dialogue, settings that don’t save, and a mute that only stops music.