Skip to content

Instantly share code, notes, and snippets.

@j201
Created November 9, 2013 19:23
Show Gist options
  • Save j201/7388824 to your computer and use it in GitHub Desktop.
Save j201/7388824 to your computer and use it in GitHub Desktop.
Function to convert multiple Web Audio AudioNodes into one AudioNode.
// 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