Reputation: 19868
Context :
This approach generates hundreds of nodes at runtime.
It's not a audio mess only because depending on the positions of the units and the camera most of them actually have a zero gain.
It works just fine on my hardware, but I would like the game to be able to run on low end hardwares.
Can I stay with a lot of nodes with a zero gain, or do I have to optimize upfront and present only nodes with a non zero gain to the web audio API to avoid performance issues ?
I can't find any information about limits in the documentation...
Upvotes: 2
Views: 306
Reputation: 89
In my experience with implementing a full-blown DAW using WebAudio nodes, it's generally better to have a constant pool of nodes that you use and re-use as necessary, rather than modifying the graph (adding / releasing nodes), which seems to be a rather expensive operation often causing audio glitches. So, you're on the right track there.
Upvotes: 1
Reputation: 6056
Generally, browsers do a good job when a gain node has zero gain. All nodes connected to the gain node will expend CPU of course, but all nodes after the gain node can be optimized because it is known that the output of the gain node is 0. In many cases the only processing is noting that the output of a node is 0, without doing any of the normal processing that would happen. (Things with memory like a delay node or filter are a bit more complicated.)
Whether that's enough for you use-case is hard to tell. But in the future, you'll have a way to tell if you're using too much CPU. See the upcoming render capacity API that is being spec'ed now.
Upvotes: 2