• Advertisement
Sign in to follow this  

XAudio2 Looping Sound

This topic is 2093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im learning XAudio2 so I can make a wrapper for it, but I can't find anything helpful on how to make a sound loop after it's stopped playing. All i know is i'm supposed to do something with the SourceVoice, and maybe the AudioBuffer inside the source voice. I'm not sure. Can anyone help?

Share this post


Link to post
Share on other sites
Advertisement
If memory serves, you cannot.
You mark it as looping before starting playing, the API loops it for you and ... it will just not stop playing. Ever. Not by itself at least.
To make it loop after it stopped playing... if memory serves... you have to destroy its current buffer queue (which would be empty anyway), fill it back with a looped buffer.
Of course, native looping and streaming don't mix if that's what you're trying to do. In that case just keep streaming looping the decoder instead.

Share this post


Link to post
Share on other sites
If a sound buffer loop or not is described in the buffer datastructure itself. When a source voice stopped playing, just enqueue the next buffer, which is marked as loop.


you have to destroy its current buffer queue (which would be empty anyway), fill it back with a looped buffer.

You don't need to destroy it, just enqueue the new buffer, maybe stop a currently running buffer.

Share this post


Link to post
Share on other sites
so any changes i want to make to the sound, looping, stop, pause or others i just submit a source buffer and it works? I know the volume is controlled by the MasterVoice.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement