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 🙏

© 2024 – Pkg Stats / Ryan Hefner

smanager

v1.4.1

Published

This JavaScript library provides a comprehensive solution for managing sound files in web applications. It includes functionalities such as loading sound files, managing audio buffers, handling languages and sound packages, and disposing of sounds to free

Downloads

49

Readme

Sound Manager

This JavaScript library provides a comprehensive solution for managing sound files in web applications. It includes functionalities such as loading sound files, managing audio buffers, handling languages and sound packages, and disposing of sounds to free up memory. This library is designed to be flexible and efficient, making it suitable for games, web applications, and any project requiring sound management.

Features

Sound Management: Load and manage sound files efficiently with support for audio contexts and buffer management. Flexible Sound Atlas: Use a sound atlas to organize sounds into packages, allowing for easy management and loading of grouped sounds. Event Handling: Extendable event handling with a disposable pattern for clean-up and memory management. Language Support: Manage sounds across different languages, allowing for easy localization of your application. Disposable Sound Items: Dispose of sounds or entire packages when they are no longer needed, helping to keep the memory footprint low. Dynamic Loading: Load sounds dynamically from a URL, supporting both .webm and .mp4 file formats. Prioritization: Set load priorities to control the order in which sounds are loaded, ensuring critical sounds are loaded first.

Installation

To use this library, include the JavaScript file in your project. You can copy the content directly into a .js file in your project, or import it as a module if your project supports ES6 modules.

Usage

Initializing the Sound Manager Create a new instance of the SoundManager class to start managing your sounds. You can specify an initial sound atlas, audio context, and other configurations during instantiation. See @jadujoel for information about the atlas, setting up the sound backend, and encoding sound files.

const manager = new SoundManager({
    atlas: {}, // Your sound atlas object
    context: new AudioContext({ sampleRate: 48000 }), // Optional audio context
    path: "./encoded/", // Path to your sound files
    language: "en", // Initial language setting
});

Loading Sounds

Load a sound atlas from a URL or set an atlas directly using loadAtlas or setAtlas. After setting the atlas, you can load specific packages or all sounds using loadPackages or loadEverything.

await manager.loadAtlas("https://example.com/sounds.atlas.json");
await manager.loadEverything(); // Load all sounds specified in the atlas

Managing Languages and Packages Change the language or switch between different sound packages easily:

manager.setLanguage("fr"); // Switch to French language sounds
manager.setPackageByName("background_music"); // Switch to a specific sound package

Playing Sounds

After loading, retrieve the audio buffer for a sound and play it using the AudioContext:

if (buffer) {
    const source = manager.context.createBufferSource();
    source.buffer = manager.requestBufferSync("sound_name");
    source.connect(manager.context.destination);
    source.start();
}

Disposing Sounds

Dispose of sounds that are no longer needed to free up memory:

await manager.disposePackage("temporary_sounds"); // Dispose of a specific package
await manager.dispose(); // Dispose of all sounds and the sound manager itself