Original Post
In a game with large levels and large numbers of characters, I''m wondering what the "best" way to manage a potentially huge number of sounds would be.
The problem is this. Imagine you have a group of five bad guys standing together, each of whom have a gun they can fire. It''s the same gun so it makes the same sound. That''s five instances of the same gun sound that could potentially be played at any given time, so having a table of game sounds with a different sound in each entry is inadequate since only one instance of the gun sound will be allowed to play correctly.
One solution I thought of would be to create a fixed number (maybe 16) of empty DirectSound sound buffers, into which raw sound data would get streamed whenever a sound needed to be played. When the sound was done being played the buffer would be returned to an "empty" state, ready to be reused.
Another solution I thought of was to simply create a DirectSound sound buffer which contained the sound in its entirety. The sound buffer would be Released() when the sound was done playing. I haven''t tried this out yet, and I don''t know how good I feel about dynamically creating and destroying DirectSound objects so often. Also, latency during the creation phase may be an issue.
In any case, I''m curious to know what everybody else is doing out there and eager to hear any kind of advice anybody might have to offer. Thanks.
-Derek