miaoda-game-sfx-generator
v0.3.1
Published
Browser-first procedural game sound effects with distinct seeded palettes and optional WAV export.
Downloads
764
Maintainers
Readme
miaoda-game-sfx-generator
Generate short browser sound effects from a deterministic project palette, without downloading or preloading audio assets. Use it for UI, arcade, mechanical, magical, or other compact game feedback; music, voices, ambience, and realistic Foley need separate audio.
pnpm add miaoda-game-sfx-generatorimport {createSfxPlayer} from 'miaoda-game-sfx-generator';
const sfx = createSfxPlayer({projectSeed: 'clockwork-castle', style: 'mechanical'});
await sfx.unlock(); // call from the first user gesture
sfx.play('jump');
sfx.play('hit');Built-in IDs: alert, explosion, hit, jump, land, pickup, power-up, shoot, ui-cancel, ui-click, and ui-confirm. A seed reproduces the same palette and shuffled variants; changing it changes pitch and texture.
Custom names and tone
const sfx = createSfxPlayer({
projectSeed: 'clockwork-castle',
style: 'mechanical',
tone: {brightness: 0.45, roughness: 0.7, weight: 0.65},
sounds: [
{id: 'enemy-laser', kind: 'shoot', variants: 5},
{id: 'boss-hit', kind: 'hit', variants: 4, tone: {weight: 0.8}},
],
});
sfx.play('enemy-laser', {volume: 0.8, pan: -0.25});Styles are arcade, magic, mechanical, retro, and soft. Tone values are 0..1: brightness emphasizes high frequencies, roughness adds texture, and weight favors lower pitch and longer decay.
play() returns a handle with stop() and an ended promise. Use setVolume, setMuted, stopAll, and destroy to control the player lifecycle. Browser autoplay rules require unlock() after a user gesture.
