rserota / wad

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

Adding Stronger Sound Caching/Grouping Functionality #143

Closed frastlin closed 9 months ago

frastlin commented 1 year ago

Hello, I am wondering if caching/grouping functionality, similar to HowlerJS could please be implemented? There are two problems with how Wad handles sounds:

  1. A sound environment with thousands of objects loading from a sound bank of 20-50 sounds is gigs of ram in Wad, instead of the KBs of ram it is in Howler. This is because the same buffer source is used across different instances of that sound and play function in Howler, rather than duplicating the buffer in Wad. Wad will have a Howl sound, and every time play is called, an ID is returned from play, allowing for sound manipulation.
  2. When the browser is asked to play the thousands of sounds at once in Wad, it chokes and dies in Wad, but handles the same number of sounds in Howler just fine.

Wad has many other features Howler does not have, but this caching/grouping functionality is currently critical for us to continue development.

rserota commented 1 year ago

I could probably implement some form of caching.

Can you show me a minimal example that demonstrates the issue? How are you measuring RAM usage?

rserota commented 1 year ago

The latest version of Wad (4.13.1) now has some basic caching for audio files, based on the source URL. This happens automatically, but you can opt out of this behavior by passing useCache: false into the constructor. I'm not sure if this will completely solve the RAM issues, but at least you won't need to make as many HTTP requests.