Hi,
I am trying to use xaudio2 in my C++ project to add some sound to a simple 2D space shooter I have made. I am trying to get sound effects for the shooting. Each time I shoot, the playBackAudio() function is called which contains the two lines required to play back my .wav file.
The trouble is, each time the sound is played, the program waits for the sample to complete before playing the next (it queues up). I tried putting the FlushSourceBuffer() in which I thought would flush the buffer and stop the sample to allow the sample to be played again.
The net affect I am after is for the sound to begin to play but if the space bar (shoot) is held down, I want the next sample to interrupt the current sample and start again (if that makes sense).
I have tried putting g_source->Stop(); followed by g_source->Start(); in the function, thinking that this may help but it made no difference.
Can anyone help?
Thanks
I am trying to use xaudio2 in my C++ project to add some sound to a simple 2D space shooter I have made. I am trying to get sound effects for the shooting. Each time I shoot, the playBackAudio() function is called which contains the two lines required to play back my .wav file.
void playBackAudio() { g_source->FlushSourceBuffers(); g_source->SubmitSourceBuffer(bufferShoot.xaBuffer()); }
The trouble is, each time the sound is played, the program waits for the sample to complete before playing the next (it queues up). I tried putting the FlushSourceBuffer() in which I thought would flush the buffer and stop the sample to allow the sample to be played again.
The net affect I am after is for the sound to begin to play but if the space bar (shoot) is held down, I want the next sample to interrupt the current sample and start again (if that makes sense).
I have tried putting g_source->Stop(); followed by g_source->Start(); in the function, thinking that this may help but it made no difference.
Can anyone help?
Thanks