I found a DuplicateSoundBuffer method that seemed to be exactly what I needed. It duplicates a buffer except for the data that is shared. However, I can't get it to work properly. It still only plays 1 sound at a time.
Here is the play wav function:
Code:
BOOL Magos::MMusic::PlayWav(INT WavId, BOOL Looping, BOOL AllowMultipleSounds)
{
//Data
LPDIRECTSOUNDBUFFER TempWav;
//Aborts if the wav ID is out of bounds
if((WavId < 0) || (WavId >= NrOfWavs))
{
return FALSE;
}
//Check if multiple sounds from the same buffer are allowed
if(AllowMultipleSounds)
{
//Creates a duplicate with shared memory
if(FAILED(DirectSound->DuplicateSoundBuffer(WavList[WavId], &TempWav)))
{
return FALSE;
}
//Adds the duplicate buffer to the play list
WavPlayList.push_back(TempWav);
//Play the wav
TempWav->SetCurrentPosition(0);
if(FAILED(TempWav->Play(0, 0, (Looping ? DSBPLAY_LOOPING : 0))))
{
return FALSE;
}
//Return success
return TRUE;
}
//Play the wav
WavList[WavId]->SetCurrentPosition(0);
if(FAILED(WavList[WavId]->Play(0, 0, (Looping ? DSBPLAY_LOOPING : 0))))
{
return FALSE;
}
//Return success
return TRUE;
}