Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get connected inputs and outputs?

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.

like image 240
katspaugh Avatar asked May 10 '26 18:05

katspaugh


1 Answers

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.

like image 162
Kevin Ennis Avatar answered May 12 '26 08:05

Kevin Ennis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!