Created
February 9, 2017 20:02
-
-
Save notgiorgi/5036dad6409bf5fc3415795193155b34 to your computer and use it in GitHub Desktop.
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
window.audioContext = window.audioContext||window.webkitAudioContext; //fallback for older chrome browsers | |
var context = new AudioContext(); | |
context.createGain = context.createGain||context.createGainNode; //fallback for gain naming | |
var gainL = context.createGain(); | |
var gainR = context.createGain(); | |
var splitter = this.context.createChannelSplitter(2); | |
//Connect to source | |
var source = context.createMediaElementSource(document.querySelector('video')); | |
//Connect the source to the splitter | |
source.connect(splitter, 0, 0); | |
//Connect splitter' outputs to each Gain Nodes | |
splitter.connect(gainL, 0); | |
splitter.connect(gainR, 1); | |
//Connect Left and Right Nodes to the output | |
//Assuming stereo as initial status | |
gainL.connect(context.destination, 0); | |
gainR.connect(context.destination, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment