Advertisement Jump to content
Sign in to follow this  

DirectSound, Streaming Buffers

This topic is 4909 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

Hi Ive problems to set up my streaming buffers with DirectSound. The documentation is quite bad, I dont understand how the Event thing works. Plz point me ouy to a good tutorial or if its easy tell me what Ive to do. thanks in advance

Share this post

Link to post
Share on other sites
It's not too complicated. You should create sound buffer with sufficient length. For examle one second or fewer. Buffer must be created with flag DSBCAPS_CTRLPOSITIONNOTIFY. Than slice this buffer into small pieces. I use only two halves, it's enough. Set notification events on each pieces, i.e. in our example in the middle of buffer and at the end of buffer.

pSoundBuffer->QueryInterface (IID_IDirectSoundNotify8, (LPVOID*)&lpDsNotify)

// PositionNotify - setting offsets and events ...
// events create with CreateEvent()
// do not use DSBPN_OFFSETSTOP as the end offset
lpDsNotify->SetNotificationPositions (2, (LPCDSBPOSITIONNOTIFY)&PositionNotify)

That's it. Play buffer with DSBPLAY_LOOPING flag. Test the events with WaitForSingleObject() or WaitForMultipleObjects() in same or another thread, it's up to you. When the event become signaled update related piece of buffer. And one advise. Create stream buffers in software (DSBCAPS_LOCSOFTWARE), onterwise the events may fire also on stopped buffers.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!