Code Monkey home page Code Monkey logo

agk-soundobject's Introduction

#AGK-SoundObject

Quick wrapper around Howler to improve preloading of sounds and loading sounds from memory

When you need to load a lot of sounds and those sounds aren't in audio sprites it can take a lot of time. Also, loading a lot of files at once sometimes messes up the webserver or your connection. This wrapper allows you to queue files to be loaded which will load one after another to circumvent theseproblems. Not the most elegant solution, however it does fix those problems. It also wraps the API of whatever sound library in use, so it can be quickly switched out without rewriting a lot of the code in the actual game.

installation

Using NPM: npm install agk-soundobject

usage

import so from "agk-soundobject"

// By default, SoundObject tries to determine the best extension to use. This can be overridden. // Set the sound directory so.directory = "./sounds/"; // set the extension so.extension = ".webm";

// load the meow.webm file in the sounds directory. const sound = so.create("meow"); // play the sound sound.play(); // change volume to 50% sound.volume = 0.5; // Play the sound at half speed sound.playbackRate = 0.5; // check if the sound is playing console.log(sound.playing); // check the current time console.log(sound.currentTime); // Destroy the sound sound.destroy();

Contributing

This library needs major refactoring at the moment. It will probably change code-wise, but the API will stay similar. If you want to help make it better it would be greatly appreciated.

License

This code is MIT licensed. More info in LICENSE.md

agk-soundobject's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.