Created
February 7, 2013 12:00
-
-
Save addyosmani/4730501 to your computer and use it in GitHub Desktop.
Reversing audio (old WebAudio sample)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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