XAudio2 Looping Sound

Started by
2 comments, last by Muzzy A 11 years, 10 months ago
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?
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.

Previously "Krohm"

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.
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.

This topic is closed to new replies.

Advertisement