Playing Direct Sound files at the same time

Started by
1 comment, last by GameDev.net 24 years, 4 months ago
You can map your sound file into memory with File Mapping technique, and then you can use memcpy function to fill your Direct Sound buffers. It means when you use the File mapping, you can access your file randomly, as RAM.
Advertisement

I've got Direct Sound working OK
but if I want to play the same sound
at the same time I have to load up a
separate copy. As an example you
have two machine gunners fireing
and one starts just before the other.
If want to hear them both you have to
load and play two separate sounds.
If you have 10 machine gunners
you would have to load 10 machine gun sounds which would eat memory.
Is there a way to play the same sound
several times at the same time and only use the one piece of memory?
Hello Davaris

A more easily method than Tuan described is to use IDirectSound: uplicateSoundBuffer like that:

pDS; // the directsound object
pDSB1; // i assume that this is your original soundbuffer which is properly initialized
pDSB2; // the second one

pDS->DuplicateSoundBuffer(pDSB1, pDSB2);

Please look at the DX7 SDK documentation for more details.

VirtualNext

This topic is closed to new replies.

Advertisement