XAudio2 How to Get Multiple Sounds to Play at the Same Time

https://pastebin.com/q300rp98

hey guys I have been working on trying to learn XAudio2, but I have been having a lot of trouble getting my proof-of-concept working. I have gotten 2 sounds playing simultaneously (bg music and fire effect); however, I can't seem to figure out how to get 2 sounds to play simultaneously. I tried making a Pool of SourceVoices, then calling GetState to see if that voice currently has UINT32 BuffersQueued != 0; if it did I would choose another Voice from the pool. Unfortunately, I can't seem to get it to work. Anyone with XAudio experience have any tips? Code posted above but of course don't feel like you need to read it, I would appreciate both specific and non-specific advice.

Edited by Blu342 on Reason: Initial post
To do that you create another IXAudio2SourceVoice, submit its buffer and call Start on it. Basically you create one master voice and then as many source voices as you want simultaneously playing music/sounds.

Edited by Mārtiņš Možeiko on
hmmm i believe i tried that and it didn't quite work, but maybe i went wrong somewhere. i'll give it another try tomorrow and post back if i encounter some error.

is GetState the best way to know if a clip ends, because i want to use a Pool of these things and I tried using GetState to figure out whether I could reuse that element.

Edited by Blu342 on
ok it works now. thanks. i probably just made a mistake when writing my first version.

Edited by Blu342 on