Created
December 3, 2012 02:04
-
-
Save kevincennis/4192135 to your computer and use it in GitHub Desktop.
invert polarity
This file contains 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 url = 'monoSound.wav' | |
, audio = new Audio(url) | |
, context = new webkitAudioContext() | |
, processor = context.createJavaScriptNode(512, 1, 1) | |
, sourceNode | |
audio.addEventListener('canplaythrough', function(){ | |
sourceNode = context.createMediaElementSource(audio) | |
sourceNode.connect(processor) | |
processor.connect(context.destination) | |
audio.play() | |
}, false) | |
processor.onaudioprocess = function(evt){ | |
var input = evt.inputBuffer.getChannelData(0) | |
, output = evt.outputBuffer.getChannelData(0) | |
, len = input.length | |
, i = 0 | |
for ( ; i < len; i++ ) output[i] = -1 * input[i] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment