Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/luciferous/Sound

Partial JS interface to ActionScript's Sound class
https://github.com/luciferous/Sound

Last synced: 3 months ago
JSON representation

Partial JS interface to ActionScript's Sound class

Awesome Lists containing this project

README

        

Sound

A Javascript wrapper around AS3 Sound.

## Usage

Load a sound file and play it.


Sound.initialize();
var s = new Sound();
s.load("testsound.mp3");
s.play();

Stream dynamically generated audio.


Sound.initialize();
var s = new Sound();
var factor = (2 * Math.PI) / 44100.0;
var feed = function() {
var samples = [];
for (var i = 0; i < 2048; i++) {
var sample = 1 + Math.sin(i * factor) * 32767;
samples.push(String.fromCharCode(sample));
}
s.buffer(samples.join(""));
setTimeout(feed, 200);
};
feed();