New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Nesting AudioNodes #2436
Comments
I remember there were a bunch of experiments to try to this using JS libraries. I can't seem to find any references (I'm just getting rusty), but I remember seeing a bunch of blog posts/talks about this in the past. We kind of tried to do this (a long time ago) with https://github.com/sonoport/soundmodels, where the "SoundModels" are Javascript objects behaved almost like WebAudio Source Nodes. They can be connected to and connected form. They had The trick is to use GainNodes at the beginning and end of your chain of AudioNodes to help with the connections. |
It was discussed in the past (see #251) but the discussion ended up with "use AudioWorklet". There have been multiple attempts to do this properly, but we have not seen anything worthy of standardization. So people are using homemade solutions in their projects. As @notthetup mentioned above, the trick is to proxy input/output with the gain node. I personally prefer Max's inlet/outlet approach for this kind of thing. Perhaps something like this: class AmpNode extends ContainerNode {
#amp;
constructor(context, container) {
super(context);
this.#amp = new GainNode(context);
container.inlet.connect(this.#amp).connect(container.outlet);
container.registerParameter('volume', this.#amp.gain);
}
}
const context = new AudioContext();
const osc = new OscillatorNode(context);
const amp = new AmpNode(context);
osc.connect(amp).connect(context.destination);
amp.volume; // is AudioParam. Obviously, this approach needs new APIs ( |
Action items from TPAC: Experiment with extending GanNode and investigate if it's feasible. |
It would be helpful for modularization if there was some kind of „ContainerNode“ that can contain an arbitrary network of AuudioNodes and can be connected like an AudioNode on the outside. That would make it possible to distribute synthesizers including effects like reverb and delay as npm packages, that can be connected to an existing AudioNode network in a client project easily.
The text was updated successfully, but these errors were encountered: