Last Updated: February 25, 2016
·
438
· kfwerf

Basic phase cancellation

Got this from Licson.net but nevertheless it's an awesome tiny module you can include. Just attach it to your audioContext and it should try to delete all the audio in the middle of the track, as they would with stereo tracks. Mono won't work.

class VoiceCancellation
        constructor: ( @_audioContext ) ->
            @audioProcessor = @_audioContext.createScriptProcessor 4096
            @audioProcessor.onaudioprocess = ( e ) ->
                inputOne = e.inputBuffer.getChannelData 0
                inputTwo = e.inputBuffer.getChannelData 1
                outputOne = e.outputBuffer.getChannelData 0
                outputTwo = e.outputBuffer.getChannelData 1


                for i in inputOne
                    outputOne[_i] = (inputOne[_i] - inputTwo[_i]) / 2
                    outputTwo[_i] = (inputTwo[_i] - inputOne[_i]) / 2

            @audioProcessor