Reputation: 49
I'm reading about custom audio effects with web audio: http://www.html5rocks.com/en/tutorials/casestudies/jamwithchrome-audio/
An example they give is this delay loop
var SlapbackDelayNode = function(){
//create the nodes we’ll use
this.input = audioContext.createGainNode();
var output = audioContext.createGainNode(),
delay = audioContext.createDelayNode(),
feedback = audioContext.createGainNode(),
wetLevel = audioContext.createGainNode();
//set some decent values
delay.delayTime.value = 0.15; //150 ms delay
feedback.gain.value = 0.25;
wetLevel.gain.value = 0.25;
//set up the routing
this.input.connect(delay);
this.input.connect(output);
delay.connect(feedback);
delay.connect(wetLevel);
feedback.connect(delay);
wetLevel.connect(output);
this.connect = function(target){
output.connect(target);
};
};
My question is this:
Is there any compelling reason to have the output
gain node? Wondering if it's there for educational reasons, or if it is actually serving a purpose which I've not grasped.
You could directly connect the wetLevel
node to the target, and that would save you having to create the output
node.
this.connect = function(target){
wetLevel.connect(target);
};
Upvotes: 0
Views: 88
Reputation: 13908
You could skip the output node. It's mostly there as a convenience, to be able to quickly and easily disconnect the output of the subgraph in one go (rather than having to disconnect from two different nodes). You don't always need this kind of convenience.
Upvotes: 1