PDA

View Full Version : OT heads up - google canary build has webaudio support



zed
05-13-2011, 02:37 PM
Its had it a while for mac OS users but now its available for windows/linux users.

Yes its not crossbrowser compatible but its about the best we have at the moment (since the audio tag is so gimped is near useless)

Also since theres no hello world example heres one I wrote


var audiocontext = new webkitAudioContext();
var soundBuffer;

function loadSound(url) {
var request = new XMLHttpRequest();
request.open("GET", url, true);
request.responseType = "arraybuffer";

request.onload = function() {
soundBuffer = audiocontext.createBuffer(request.response, true);
}

request.send();
}

function playSound() {
var source = audiocontext.createBufferSource();
source.buffer = soundBuffer;
source.connect(audiocontext.destination);
source.noteOn(0);
}