Reputation: 17899
Does a WebAudio node have access to other nodes connected to it (either as inputs or outputs)?
For example, I have a gain node and a buffer source node. The buffer source node is wired to the gain node and the gain node is connected to the final destination:
var gainNode = ac.createGainNode(); // gain node
ac.createBufferSource().connect(gainNode); // source
gainNode.connect(ac.destination);
Given only a reference to the gain node, can I get a reference to the source node? And vice versa.
Upvotes: 3
Views: 1184
Reputation: 14466
Nope. I'm not totally sure why, though. Seems like that would make a few things quite a bit easier.
EDIT:
If you're feeling adventurous, you could maybe try something crazy like this:
AudioNode.prototype.connect = (function(){
var func = AudioNode.prototype.connect;
return function(){
( this.outputs || ( this.outputs = [] ) ).push(arguments[0]);
return func.apply(this, arguments);
}
}());
Which would give connected AudioNodes
an output
array of their output nodes. You'd also have to override AudioNode.prototype.disconnect
in a similar way to remove them from the array.
This is probably a terrible idea, but might work out for you depending on what you need to do.
Upvotes: 4