npm.io
0.7.0 • Published 1 month ago

@yagejs/audio

Licence
MIT
Version
0.7.0
Deps
2
Size
92 kB
Vulns
0
Weekly
0

@yagejs/audio

Sound loading, playback, and channel mixing for the YAGE 2D game engine.

Install

npm install @yagejs/audio

Bundles @pixi/sound - no separate install required.

Usage

import { Engine } from "@yagejs/core";
import { AudioPlugin, sound } from "@yagejs/audio";

const engine = new Engine();
engine.use(new AudioPlugin({
  channels: {
    music: { volume: 0.7 },
    sfx: { volume: 1.0 },
  },
}));

Play sounds via the asset system or a SoundComponent:

const jumpSfx = sound("jump.mp3");
entity.add(new SoundComponent({ source: jumpSfx, channel: "sfx" }));

What's in the box

  • AudioPlugin / AudioManager - sound loading and playback
  • SoundComponent - attach sounds to entities with auto-cleanup
  • Channels - per-channel volume, mute, ducking
  • Spatial options - 2D positional audio via pan

Docs

Full documentation at yage.dev.

License

MIT

Keywords