Created
August 10, 2016 05:29
-
-
Save AdrienFromToulouse/46740802f6acd50430404de66b0b9d46 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
const fs = require('fs'); | |
module.exports = (audioContext) => { | |
const buffer = fs.readFileSync('/tmp/MixTwoDifferentChannels.wav'); | |
return audioContext.decodeAudioData(buffer).then((audioBuffer) => { | |
const bufSrc = audioContext.createBufferSource(); | |
const panNode = audioContext.createStereoPanner(); | |
// mostly on the left | |
panNode.pan.value = 0.9; | |
// if channelCount is set to 2 it fails to apply the correct panning. | |
panNode.channelCount = 1; | |
bufSrc.buffer = audioBuffer; | |
bufSrc.connect(panNode); | |
panNode.connect(audioContext.destination); | |
bufSrc.start(0); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment