rserota / wad

Web Audio DAW. Use the Web Audio API for dynamic sound synthesis. It's like jQuery for your ears.
MIT License
1.89k stars 160 forks source link

Have a way to controll all sounds at once #103

Closed frastlin closed 5 years ago

frastlin commented 5 years ago

Hello, I'm making a game where a user can focus on a sound and it will get louder. I want all other sounds to stop while this one sound is playing. If there was a master polywad that had all sounds, then I could just call stop on the master polywad, play the new sound and when that finishes, call play on the master wad. Now I need to loop through a list of all existing sounds and call stop and play when I want to stop and play them.

rserota commented 5 years ago

Well, you totally could just make a PolyWad and add all your other wads to it as they're created. Looping through an array is also a fine solution. I guess I could make a 'master PolyWad' that all other wads are added to, but I'm not sure if everyone would want/expect that extra layer of routing set up by default.

frastlin commented 5 years ago

precedent for this would include: pygame.mixer howler.js

Although the single class of Wad doesn't make it very easy to do global functionality.

rserota commented 5 years ago

hmm... I might have been overthinking this. I could add a global method like Wad.stopAll() that just calls stop() on every wad you've created, and Wad.setVolume() that calls setVolume() on every wad you've created. Does that sound like what you need?

frastlin commented 5 years ago

yes, I want the stop function

rserota commented 5 years ago

The latest version of Wad.js includes two new methods, Wad.stopAll() and Wad.setVolume(). Thanks for raising this issue, and good luck with your game!