Detecting the position and end of a sound

Started by
0 comments, last by lack o comments 19 years, 2 months ago
How do you detect when a sound has ended, and detect and set the position where it currently is? I have several tracks of background music for a game, and one track of menu music. I need to be able to pause it, record the position of the background track, e.g. 1 minute 13 seconds into the track, and when I unpause, to make the sound start playing again from the same point it stopped at. Also, when a track has ended, I need to be able to detect that it has ended, so I can play a different track.
Advertisement
Are you using DirectSound or DirectMusic/Audio?

In DirectSound, the "IDirectSoundBuffer8" interface has the methods: GetCurrentPosition(), SetCurrentPosition(), and GetStatus(). You can get the details of the parameters from the DirectX SDK Docs or MSDN.

In DirectMusic/Audio 'IDirectMusicSegment8' and 'IDirectMusicSegmentState' have a TON of methods for accessing and setting positions and automatic loop points, and the "IDirectMusicPerformance8" interface has even more for determining the current playing state of the segements. If would be ridiculous for me to try to list all the details here, so, as before, check it out in MSDN. Or, if you still have the DirectX 8 Docs, you can find it in there.

This topic is closed to new replies.

Advertisement