var loadSoundFile = function(url) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; xhr.onload = function(e) { context.decodeAudioData(this.response, function(decodedArrayBuffer) { buffer = decodedArrayBuffer; } }; xhr.send(); }