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

retro-audio-engine

v1.0.0

Published

Web Audio API sound synthesizer for retro game sound effects - phasers, explosions, alerts, and more

Readme

retro-audio-engine

Web Audio API sound synthesizer for retro game sound effects. Generates procedural audio without any external files - phasers, explosions, alerts, victory fanfares, and more.

Installation

npm install retro-audio-engine

Quick Start

import { audioEngine } from 'retro-audio-engine';

// Play sounds using the default singleton
audioEngine.playLaser();
audioEngine.playExplosion();
audioEngine.playVictory();

// Adjust volume (0-1)
audioEngine.setVolume(0.5);

// Mute/unmute
audioEngine.setEnabled(false);

Features

  • Zero dependencies - Pure Web Audio API
  • No external files - All sounds are procedurally generated
  • Lazy initialization - AudioContext created on first sound (browser-friendly)
  • TypeScript - Full type definitions included
  • 15+ built-in sounds - Weapons, impacts, alerts, collectibles, game states

Available Sounds

Weapons

audioEngine.playLaser();      // Sci-fi laser/phaser beam
audioEngine.playPhaser();     // Alias for playLaser
audioEngine.playTorpedo();    // Deep torpedo/missile launch
audioEngine.playMissile();    // Alias for playTorpedo

Impacts

audioEngine.playExplosion();  // White noise explosion burst
audioEngine.playHit();        // Short punchy damage sound
audioEngine.playShieldHit();  // Metallic shield deflection

Movement

audioEngine.playWarp();       // Hyperspace jump (rising sweep)
audioEngine.playHyperspace(); // Alias for playWarp
audioEngine.playDock();       // Gentle docking/landing
audioEngine.playJump();       // Platform jump/bounce

UI & Alerts

audioEngine.playClick();      // UI click/select
audioEngine.playBeep();       // Notification beep
audioEngine.playAlert(3);     // Warning alert (3 pulses)
audioEngine.playCriticalAlert(); // Urgent red alert

Game States

audioEngine.playVictory();    // Triumphant fanfare
audioEngine.playLevelComplete(); // Alias for playVictory
audioEngine.playDefeat();     // Sad game over
audioEngine.playGameOver();   // Alias for playDefeat

Collectibles

audioEngine.playCoin();       // Coin/pickup jingle
audioEngine.playPickup();     // Alias for playCoin
audioEngine.playPowerUp();    // Power-up shimmer

Custom

audioEngine.playTone(440, 0.2, 'sine');  // Custom tone

Creating Multiple Instances

import { AudioEngine } from 'retro-audio-engine';

// Create custom instances with different settings
const sfx = new AudioEngine({ volume: 0.5 });
const music = new AudioEngine({ volume: 0.3 });

sfx.playExplosion();

Volume Control

// Set volume (0-1)
audioEngine.setVolume(0.5);

// Get current volume
const vol = audioEngine.getVolume();

// Mute all sounds
audioEngine.setEnabled(false);

// Check if enabled
if (audioEngine.isEnabled()) {
  audioEngine.playClick();
}

Browser Autoplay Policy

Modern browsers require user interaction before playing audio. The AudioEngine handles this by:

  1. Lazy-initializing the AudioContext on first sound
  2. Automatically resuming suspended contexts

For best results, trigger initial sound on user interaction:

button.addEventListener('click', () => {
  audioEngine.playClick(); // Safe after user gesture
});

You can also manually resume:

await audioEngine.resume();

Sound Parameters

Some sounds accept optional parameters:

audioEngine.playLaser(0.3);   // Duration in seconds (default: 0.15)
audioEngine.playTorpedo(0.5); // Duration in seconds (default: 0.3)
audioEngine.playAlert(5);     // Number of pulses (default: 3)
audioEngine.playTone(
  880,      // Frequency in Hz
  0.5,      // Duration in seconds
  'square'  // Waveform: 'sine' | 'square' | 'sawtooth' | 'triangle'
);

TypeScript

Full TypeScript support with exported types:

import { AudioEngine, AudioEngineOptions } from 'retro-audio-engine';

const options: AudioEngineOptions = {
  volume: 0.5,
  enabled: true
};

const engine = new AudioEngine(options);

Example: Game Integration

import { audioEngine } from 'retro-audio-engine';

class Game {
  constructor() {
    // Initialize audio on first user interaction
    document.addEventListener('click', () => {
      audioEngine.playClick();
    }, { once: true });
  }

  onPlayerShoot() {
    audioEngine.playLaser();
  }

  onEnemyHit(killed: boolean) {
    if (killed) {
      audioEngine.playExplosion();
    } else {
      audioEngine.playHit();
    }
  }

  onCollectCoin() {
    audioEngine.playCoin();
  }

  onGameOver(won: boolean) {
    if (won) {
      audioEngine.playVictory();
    } else {
      audioEngine.playDefeat();
    }
  }
}

License

MIT © Luke Steuber