Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including easy-ears with all npm packages installed. Try it out:

var easyEars = require("easy-ears")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

easy-ears v0.1.0

Easy sound reactivity for your web app or experiment

EasyEars.js

Easy sound reactivity for Chrome (and Safari nightly?).

Demo page

Getting Started

First, get the code.

Second, create a new instance of EasyEars with the form:

new EasyEars(options, completeCallback);

Here are some examples:

// Create a new ears instance that will use a DOM
// element as a target for drag and dropped .mp3
ears = new EasyEars({dropTarget: document}, function(){
  console.log('song loaded!');
});

// or...

// Create one that will use an mp3 from a url
ears = new EasyEars({url: '/mp3/a_song.mp3'});

To use it, first update the audio using updateAudio(timeSmoothing). Where timeSmoothing is a value between 0.0 and 1.0.

Next, use ears.lows(), ears.mids(), and ears.highs() to get sound data back from EasyEars. These values will always be between 0.0 and 1.0.

Usage Examples:

var animate = function() {
  webkitRequestAnimationFrame(animate);
  
  // call updateAudio periodically to get latest sound data
  ears.updateAudio(0.5);

  // use the following methods to get sound data,
  // each will return a value between 0.0 and 1.0
  ears.lows();
  ears.mids();
  ears.highs();
}

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free