I'm working on a game which plays a large number of short, one-shot sound effects in very rapid succession: weapons fire, weapon impacts, unit deaths, building destruction, and so on. Part of the point of the game is that the amount of onscreen chaos can grow to absurd levels. As that happens, the number of active sounds skyrockets. This presents a few problems:
- Audio overload and unusually loud sounds due to like sounds stacking within the same frame
- Audio flanging due to like sounds playing almost, but not quite, in time with each other
- Phase cancellation due to like sounds playing almost exactly out of phase with each other
My question is: what are some ways to address these issues? I'm having a hard time finding discussion of techniques for these things.
So far, I've implemented a custom AudioMixer class which allocates a fixed-size pool of AudioSources for each unique AudioClip, and cycles through that pool as requests for that sound come in. There's also a voice-limiting mechanism on that pool which prevents a given sound from being triggered more than once every N seconds. This effectively addressed the "audio overload" issue by preventing like sounds stacking in a single frame. The flanging and phase cancellation issues seem rather trickier.
Has anyone dealt with this sort of thing before? Any ideas or suggestions?