perf: optimize audio system and implement sound prioritization

  • Refactor Source/Sink to use pre-allocated buffers and reduce heap churn in audio thread.
  • Implement priority-based sound mixing with a limit of 16 concurrent sources.
  • Move 3D sound attenuation updates to a 30 FPS timer in Scene.
  • Add randomized walk speeds for LiveRock mobs.
  • Remove atomic gain/pan in favor of synchronous updates under sink locks.

I’ve been working on optimizing the sound system, and it’s been quite a challenge. I’m not sure how this is typically handled, but I ended up limiting the number of simultaneous sound sources to 16 and implementing a prioritization system. I also attempted to reduce memory allocations by reusing buffers, although it didn’t seem to make a huge difference. I decided to keep those changes anyway as they’re slightly more efficient and I’d rather not revert them now.

Previous