The XAudio2 graph

Started by
0 comments, last by Iveco 13 years, 2 months ago
Looking at XAudio2 to use as the sound system in a personal project (since Ive never done lower level sound stuff before and figured id give it a try, even if only to make space invaders with 7.1 surround sound :) ) .

It seems to me that there is many cases where the audio system needs to know about other voices. For example when shutting the game down I cant delete a voice while their are other voices sending to it, however in many places playing a sound is kind of "fire and forget" (eg an explosion) as far as the rest of the game cares, so I dont have that voice object to delete first until after xaudio2 gives me the stream end callback...

Have I missed something here that would let me walk the XAudio2 voice graph, or am I just going about this the wrong way? Or is the best general way for me to maintain my own audio graph even though there must be one of some sorts internally already???
Advertisement
You can use XAudio2 callbacks or use the bufferstate of the SourceVoice directly, and check if this is empty.

XAUDIO2_VOICE_STATE state;
sourcevoice->GetState(&state);
if (state.pCurrentBufferContext == NULL && state.BuffersQueued == 0)
{
// SOUND FINISHED
}


When you shutdown the game, you can stop all you running SourceVoices and delete them afterwards (prior shutting down XAudio2).
Obviously this will produce glitches, lower the volumes for a few frames (fadeoff) until destroying it.

This topic is closed to new replies.

Advertisement