npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@djodjonx/gwen-plugin-audio

v1.0.0

Published

GWEN Audio Plugin

Readme

#@djodjonx/gwen-plugin-audio

GWEN Audio Plugin — Web Audio API integration

Manage sound effects, background music, and audio playback in your GWEN game.

Installation

npm install@djodjonx/gwen-plugin-audio

Quick Start

Register the Plugin

// gwen.config.ts
import { defineConfig } from '@djodjonx/gwen-kit';
import { AudioPlugin } from '@djodjonx/gwen-plugin-audio';

export default defineConfig({
  plugins: [new AudioPlugin({ masterVolume: 0.8 })],
});

Preload and Play Sounds

import type { EngineAPI } from '@djodjonx/gwen-engine-core';

export function createAudioSystem(api: EngineAPI) {
  const audio = api.services.get('audio');

  // Preload sounds
  audio.preload('jump', '/sounds/jump.wav');
  audio.preload('coin', '/sounds/coin.wav');
  audio.preload('music', '/sounds/background.mp3');

  // Play a sound effect
  audio.play('jump');

  // Play looping background music
  audio.play('music', { loop: true, volume: 0.5 });
}

API Reference

AudioPlugin(config?)

Creates an audio plugin instance.

Options:

  • masterVolume?: number — Global volume multiplier (0-1, default: 1)

preload(name: string, url: string)

Preload a sound file for later playback.

  • name — Identifier for the sound
  • url — Path to audio file (WAV, MP3, etc.)

play(name: string, options?)

Play a preloaded sound.

Options:

  • volume?: number — Volume multiplier (0-1)
  • pitch?: number — Playback rate/pitch
  • loop?: boolean — Loop the sound

stop(name: string)

Stop all instances of a playing sound.

setMasterVolume(volume: number)

Change the global master volume.

Examples

Background Music with Controls

const audio = api.services.get('audio');

// Start music
audio.preload('bgm', '/music/theme.mp3');
audio.play('bgm', { loop: true, volume: 0.3 });

// Later, stop it
audio.stop('bgm');

Sound Effects with Variations

// Preload multiple hit sounds
audio.preload('hit1', '/sfx/hit1.wav');
audio.preload('hit2', '/sfx/hit2.wav');
audio.preload('hit3', '/sfx/hit3.wav');

// Play a random one on collision
const hits = ['hit1', 'hit2', 'hit3'];
const random = hits[Math.floor(Math.random() * hits.length)];
audio.play(random, { pitch: 0.8 + Math.random() * 0.4 });

Browser Compatibility

Uses the Web Audio API. Supported in all modern browsers:

  • Chrome/Edge 14+
  • Firefox 25+
  • Safari 6+

See Also