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

webaudioloader

v1.0.4

Published

Caching Loader (with optional decode) audio files to be used with WebAudio

Downloads

224

Readme

WebAudioLoader

Caching Loader and Decoder for audio files to be used with Web Audio.

Usage:

var WebAudioLoader = require("webaudioloader");

var audioContext = new AudioContext();

var options = {
	context : audioContext,
	cache : true,
	maxCacheSize : 2000,
	onprogress : function (event){
		console.log('Loading some files...', event.loaded/event.total);
	}
}

var wal = new WebAudioLoader(options);

wal.load('http://www.example.com/audio.mp3', {
		onload : function (err, buffer){
		if(!err){
			console.log('Loaded file of duration', buffer.duration);
		}
	},
});

Why WebAudioLoader

  • Easy API (deals with loading and decoding audio for you) for XHR loading of audio.
  • Uses LRU Cache for caching decoded audio.
  • Uses node style callbacks (err, buffer) to return decoded buffers.
  • Registers a global single instance and returns a reference if one is found.

Note

  • Web Audio only works in a browser (for now), so does this module.

Install

  1. With npm do:

    npm install webaudioloader

  2. Use browserify:

    var WebAudioLoader = require('webaudioloader')

    and

    browserify myapp.js > bundle.js

  3. Standalone (AMD, global object) builds are avilable here.

API

Constructor

eg : var wal = new WebAudioLoader(options);

  • option object can have following optional properties

    • cache : boolean - enable/disable cache globally. Default is true.
    • maxCacheSize : Number - maximum size in kB of cached audio buffers. Default is 1000.
    • onload : Function - global callback when a load operation is complete. The callback has node style return arguments callback(err, buffer).
    • onprogress : Function - global callback when a load operation is in progress. The callback return a progress Event.
    • context : AudioContext - an AudioContext to use for decoding the audio.

Properties

  • onload : Function - global callback when a load operation is complete. The callback has node style return arguments callback(err, buffer).

    eg : wal.onload = function(){};

  • onprogress : Function - global callback when a load operation is in progress. The callback return a progress Event.

    eg : wal.onprogress = function(){};

  • cache : boolean - enable/disable cache globally.

    eg : wal.cache = false;

Methods

  • load : Main API method to load ()and decode) a given AudioFile.

    eg :

    wal.load('http://www.example.com/audio.mp3');
    wal.load([object File]);
    wal.load('http://www.example.com/audio.mp3', options);
    • the source argument can either be a URL String or a File object

    • option object can have following optional properties

      • decode : boolean - toggle if the audio file should be decoded. If decoded the onload callback returns an AudioBuffer, else it returns an ArrayBuffer.
      • cache : boolean - if the audio from this specific load call should be cached. Overrides the global property.
      • onload : Function - callback when this specific load operation is complete. The callback has node style return arguments callback(err, buffer).
      • onprogress : Function - callback when this specific load operation is in progress. The callback return a progress Event.
  • flushCache : Resets the internal cache of the loader.

    eg : wal.flushCache();

License

MIT