Created
November 9, 2013 19:23
-
-
Save j201/7388824 to your computer and use it in GitHub Desktop.
Function to convert multiple Web Audio AudioNodes into one AudioNode.
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
// Wraps multiple audioNodes into one node | |
function wrapNodes(context, inputNodes, outputNodes) { | |
var wrapper = context.createGain(); | |
inputNodes.forEach(function(node) { | |
wrapper.connect(node); | |
}); | |
wrapper.connect = function(node) { | |
outputNodes.forEach(function(outputNode) { | |
outputNode.connect(node); | |
}); | |
}; | |
wrapper.disconnect = function() { | |
outputNodes.forEach(function(outputNode) { | |
outputNode.disconnect(); | |
}); | |
}; | |
return wrapper; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment