Skip to content

Instantly share code, notes, and snippets.

@kishalmi
Created April 30, 2014 14:59
Show Gist options
  • Save kishalmi/665fe7a8953a5b91cc3a to your computer and use it in GitHub Desktop.
Save kishalmi/665fe7a8953a5b91cc3a to your computer and use it in GitHub Desktop.
reverse (copy of) webaudio buffer
request.onload = function () {
context.decodeAudioData(request.response, function (buf) {
// store as forward buffer
buffer = buf;
// create a reversed copy
bufferReversed = context.createBuffer(buf.numberOfChannels, buf.length, buf.sampleRate);
for (var i = 0; i < buf.numberOfChannels; i++)
bufferReversed.getChannelData(i).set(
Array.prototype.reverse.call(new Float32Array(buf.getChannelData(i)))
);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment