Created
March 13, 2020 09:13
-
-
Save hikerpig/8616ddfb2106b8799172e178a2f2f914 to your computer and use it in GitHub Desktop.
Web Audio tricks
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
// copy from https://stackoverflow.com/questions/9874167/how-can-i-play-audio-in-reverse-with-web-audio-api | |
var context = new AudioContext(), | |
request = new XMLHttpRequest(); | |
request.open('GET', 'path/to/audio.mp3', true); | |
request.responseType = 'arraybuffer'; | |
request.addEventListener('load', function(){ | |
context.decodeAudioData(request.response, function(buffer){ | |
var source = context.createBufferSource(); | |
Array.prototype.reverse.call( buffer.getChannelData(0) ); | |
Array.prototype.reverse.call( buffer.getChannelData(1) ); | |
source.buffer = buffer; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment