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

sonicgrid-sdk

v1.0.2

Published

Live SFX Generator SDK for HTML5 games - Let players generate AI-powered sound effects during gameplay

Readme

SonicGrid SDK

Live SFX Generator SDK for HTML5 games. Let players generate AI-powered sound effects during gameplay via a hotkey-triggered dialog.

Features

  • Hotkey-triggered sound generation dialog (default: *)
  • Automatic game pause/resume integration
  • Multiple audio library adapters: Pixi.js, Three.js, Howler.js, Web Audio API
  • Auto-detection of your game's audio system
  • Sound caching and management
  • Cross-origin message protocol for iframe integration

Installation

Load from SonicGrid (Recommended)

The easiest way to get started is to load the SDK directly from the SonicGrid website:

<script src="https://sonicgrid.org/sdk/sonicgrid-sdk.umd.js"></script>

Alternative mirror:

<script src="https://soundgrid.replit.app/sdk/sonicgrid-sdk.umd.js"></script>

npm Package

For bundled projects, install via npm:

npm install sonicgrid-sdk

Other CDN Options

You can also use unpkg or jsdelivr:

<!-- unpkg -->
<script src="https://unpkg.com/sonicgrid-sdk@latest/sonicgrid-sdk.umd.js"></script>

<!-- jsdelivr -->
<script src="https://cdn.jsdelivr.net/npm/sonicgrid-sdk@latest/sonicgrid-sdk.umd.js"></script>

Quick Start

Script Tag (UMD)

When loading from sonicgrid.org via script tag, SonicGridSDK is available as a global:

<!DOCTYPE html>
<html>
<head>
  <script src="https://sonicgrid.org/sdk/sonicgrid-sdk.umd.js"></script>
</head>
<body>
  <script>
    const sdk = SonicGridSDK.init({
      hotkey: '*',
      adapter: 'auto',
      onPause: () => game.pause(),
      onResume: () => game.resume(),
      onSoundReady: ({ id, prompt, duration, play }) => {
        console.log(`Sound "${prompt}" ready (${duration}s)`);
        play();
      },
    });
  </script>
</body>
</html>

ES Module

For bundled projects using npm:

import { SonicGridSDK } from 'sonicgrid-sdk';

const sdk = SonicGridSDK.init({
  hotkey: '*',
  adapter: 'auto', // or 'pixi', 'three', 'howler', 'native'
  onPause: () => {
    game.pause();
  },
  onResume: () => {
    game.resume();
  },
  onSoundReady: ({ id, prompt, duration, play }) => {
    console.log(`Sound "${prompt}" ready (${duration}s)`);
    // Optionally play immediately
    play();
  },
});

// Later: clean up
sdk.destroy();

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | hotkey | string | '*' | Key to trigger the dialog | | adapter | string | 'auto' | Audio adapter: 'pixi', 'three', 'howler', 'native', or 'auto' | | adapterContext | object | {} | Engine-specific context (e.g., PIXI.sound, THREE.AudioListener) | | onPause | function | - | Called when dialog opens (pause your game) | | onResume | function | - | Called when dialog closes (resume your game) | | onSoundReady | function | - | Called when a sound is generated and ready | | originAllowlist | string[] | [] | Additional allowed origins for cross-origin communication | | dialogUrl | string | - | Custom dialog URL (for self-hosted setups) |

API Reference

Dialog Control

sdk.openDialog();     // Open the dialog programmatically
sdk.closeDialog();    // Close the dialog
sdk.toggleDialog();   // Toggle dialog open/closed
sdk.isDialogOpen();   // Check if dialog is open

Sound Management

sdk.playSound(id);              // Play a registered sound
sdk.stopSound(id);              // Stop a specific sound
sdk.stopAllSounds();            // Stop all sounds
sdk.getSounds();                // Get Map of all registered sounds
sdk.hasSound(id);               // Check if sound exists
sdk.registerSound(id, buffer);  // Register sound manually
sdk.unregisterSound(id);        // Remove a sound

SDK Control

sdk.setHotkey('`');   // Change the hotkey
sdk.enable();         // Enable hotkey listener
sdk.disable();        // Disable hotkey listener
sdk.isGamePaused();   // Check if game is paused by SDK
sdk.getVersion();     // Get SDK version
sdk.destroy();        // Clean up all resources

Adapter Examples

Pixi.js

import { SonicGridSDK } from 'sonicgrid-sdk';
import { sound } from '@pixi/sound';

const sdk = SonicGridSDK.init({
  adapter: 'pixi',
  adapterContext: { sound },
  onPause: () => app.ticker.stop(),
  onResume: () => app.ticker.start(),
});

Three.js

import { SonicGridSDK } from 'sonicgrid-sdk';

const listener = new THREE.AudioListener();
camera.add(listener);

const sdk = SonicGridSDK.init({
  adapter: 'three',
  adapterContext: { listener },
  onPause: () => clock.stop(),
  onResume: () => clock.start(),
});

Howler.js

import { SonicGridSDK } from 'sonicgrid-sdk';

const sdk = SonicGridSDK.init({
  adapter: 'howler',
  onPause: () => Howler.mute(true),
  onResume: () => Howler.mute(false),
});

Web Audio API (Native)

import { SonicGridSDK } from 'sonicgrid-sdk';

const audioContext = new AudioContext();

const sdk = SonicGridSDK.init({
  adapter: 'native',
  adapterContext: { audioContext },
  onPause: () => audioContext.suspend(),
  onResume: () => audioContext.resume(),
});

Browser Support

  • Chrome 80+
  • Firefox 78+
  • Safari 14+
  • Edge 80+

Requires Web Audio API support.

Changelog

v1.0.3

  • Fixed Three.js adapter audio cleanup (memory leak in onEnded callback)
  • Fixed Pixi.js adapter base64 conversion for large audio files
  • Improved WebAudio adapter initialization with null safety
  • Added null checks to isDialogOpen() for destroyed SDK instances
  • Fixed hotkey normalization for edge cases with undefined keys
  • Added error handling for dialog creation failures

v1.0.2

  • Initial stable release
  • Support for Pixi.js, Three.js, Howler.js, and Web Audio API
  • Hotkey-triggered dialog with pause/resume hooks
  • Cross-origin message protocol for iframe isolation

License

MIT