Timbre.js

JavaScript Library for Objective Sound Programming
system requirements: Chrome 14- or Firefox 4-

WavDecoder

Load a wav file and store it to the buffer.

Constructor

T("wav", src="public/audio/amen.wav", loop=true).load();

// src  [String]  The url of an wav file to load
// loop [Boolean] Looping
        

Properties

wav.src         // [String]   The url of an wav file to load
wav.loop        // [Boolean]  Looping

wav.currentTime // [Number]   Current position in msec of the buffer
wav.reversed    // [Boolean]  Play backwards

wav.isLoaded    // [Readonly] 'true' when loaded wav and stored
wav.duration    // [Readonly] The duration of the buffer
        

Methods

// Async load an wav file and store it to the buffer
wav.load();


// Return new T("wav") instance which refers to the same buffer
wav.clone();


// Return new T("wav") instance which has the extracted buffer
wav.slice(begin=0, end=1000);
        

Events

// Script to be run when the buffer has reach the end
wav.onended = function() {};


// Script to be run when the buffer has reach the end and loop
wav.onlooped = function() {};


// Scripts to be run when the meta data is loaded
wav.onloadedmetadata = function(res) {};


// Scripts to be run when an audio data is loaded
wav.onloadeddata = function(res) {};


// Scripts to be run when an error occurs when the file is being loaded
wav.onerror = function() {};
        

Example: Reversed wav

wav.clone().set("reversed", true).play();
        

Example: Beat from slice wav

wav.slice(280, 280+214).play();
        

See Also:

T("audio")