locked
XAudio2: What is the Best Practice for Overlapping Sound Effects ?

    Question

  • What is the best way to overlap sound effects using XAudio2?

    Right now, I'm creating multiple SourceVoices and rotating through them submitting the same wave file's SourceBuffers and calling play. When one finishes playing, I put it back in the pool to be reused.

    That definitely works but is that best practice or the only way? 


    Larry Olson

    Monday, May 14, 2012 4:00 AM

Answers

  • If you want multiple sounds playing at once, you have multiple XAudio2SourceVoice instances. You can have them share the same audio data or not as you choose as the application maintains full ownership of the audio sample data memory at all times.

    You should take some time to read through the entire XAUDIO2 programmer's guide to make sure you have all the concepts down. You may also want to check out some older Gamefest audio presentations as well--they are mostly about the legacy DirectX SDK versions of XAUDIO2, but the design is essentially the same.

    http://blogs.msdn.com/b/chuckw/archive/2012/05/15/learning-xaudio2.aspx

    Tuesday, May 15, 2012 7:44 PM

All replies

  • Just call    IXAudio2SourceVoice::Start when the audio is finished.

    NEU_ShieldEdge

    Tuesday, May 15, 2012 3:38 AM
  • That queues the next voice but does not overlap them.

    Larry Olson

    Tuesday, May 15, 2012 1:42 PM
  • If you want multiple sounds playing at once, you have multiple XAudio2SourceVoice instances. You can have them share the same audio data or not as you choose as the application maintains full ownership of the audio sample data memory at all times.

    You should take some time to read through the entire XAUDIO2 programmer's guide to make sure you have all the concepts down. You may also want to check out some older Gamefest audio presentations as well--they are mostly about the legacy DirectX SDK versions of XAUDIO2, but the design is essentially the same.

    http://blogs.msdn.com/b/chuckw/archive/2012/05/15/learning-xaudio2.aspx

    Tuesday, May 15, 2012 7:44 PM