Is it more expensive to create and close web audio oscillators or to keep running and manipulate the gain?

93 Views Asked by At

So I have a web app I'm building that has several different possible sounds that can be triggered by a button press. Something like a radio list of options and you choose your option and then hit the play button and it plays.

previously with only 2 sources, I created the entire web audio pathway (oscillator > gain > pan > destination) and then started the oscillator and just changed the with the gain node to turn on and off different sounds. It seems like a bad idea though to have 6 web audio sources always running (but with two of them at 0 gain).

So my question is this: Is it better to run 6 sources, and toggle the gain node for the one or two I want to be on and the other two to be 0 (to "turn them off"), or is it better to start and stop the different oscillator nodes (leaving them for garbage collection) on each cycle.

In a given session, a user may create hundreds of little boops and beeps at different frequencies - so it feels like trouble to control creating and destroying each one. But at the same time, I don't want my apps performance to suffer by constantly running 6 web audio sources in the background.

Any thoughts or ideas?

0

There are 0 best solutions below