Skip to content

Instantly share code, notes, and snippets.

@addyosmani
Created February 7, 2013 12:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save addyosmani/4730501 to your computer and use it in GitHub Desktop.
Save addyosmani/4730501 to your computer and use it in GitHub Desktop.
Reversing audio (old WebAudio sample)
var context = new AudioContext(),
request = new XMLHttpRequest(),
mp3File = 'yourFile.mp3';
request.open('GET', mp3File , true);
request.responseType = 'arraybuffer';
request.addEventListener('load', function(){
context.decodeAudioData(request.response, function(buffer){
var src = context.createBufferSource();
Array.prototype.reverse.call( buffer.getChannelData(0) );
Array.prototype.reverse.call( buffer.getChannelData(1) );
src.buffer = buffer;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment