Jim
DirectSound
know when a DirectSound sound buffer has finished playing
by notification.
As the last person pointed out, you probably should just
rely on Win32 API functions for notification.
For example, let's say you want to call a function after 2 seconds
has passed. This will setup a simple callout function:
SetTimer(hMainWindow, ID_MY_TIMER, 2000, (TIMERPROC)MyTimerProc);
So, after 2000 milliseconds have passed, it will call your MyTimerProc
function, which is setup like this:
VOID CALLBACK
MyTimerProc(HWND hWnd, UINT timer_msg, UINT timer_id, DWORD dwSysTime) {
// do something, like flip a page
}
If you know the time length of all 6 voice WAVs, you can probably
call SetTimer six different times with a different time delay for
each voice.
Scruff
accurate. Here's another way. Continually poll the sound
buffer status in your main loop.
DWORD dwStatus;
BOOL done_flag;
// get the playing status
sound_buffer->GetStatus(&dwStatus);
// sound has stopped
if(dwStatus != DSBSTATUS_PLAYING) {
done_flag = 1;
}
If it is done, set a flag. This might be even easier, since
you don't even have to know the time lengths of any sound buffers.
Scruff
1)Setup your notification interface.
2)If the sound is static, then it fits into one buffer. Setup the ONLY notification position as DSBPN_OFFSETSTOP, and only one event being triggered. If the sound is streamed, setup 3 positions, one midstream, one endstream, and the last that marks where the end of the sound would be.
3) In the notification routine, just keep track of which notification position has been triggered. If the sound is static, there's only one notification - sound stopped/completed.
I have a half-finished article I was writing on using DirectX and notifications that I can finish up if anybody shows some interest in it. It talks about all the above.
------------------
Jim Adams
Co-Designer 'The Light Befallen'
tcm@pobox.com
http://www.lightbefallen.com
IDirectSoundNotify::SetNotificationPositions()
Works like a hot-damn.
Step (2) is a big confusing step if you don't know a thing about
threads and events. I can't find a complete DirectX example
in the docs, since they have it hacked up everywhere in little
bits.
Scruff
I have the voice in 6 different languages so i cant make a timer that flips the page. I have to have the program tell the flipfunction when to start.
I know this is possible in DirectX but I can't figure out how to.
I'm using DX6.1 and VC++ 6.0
Cheers
_grinder_
------------------

If you have six different sound buffers, you probably have
to create six different event handles like:
HANDLE hEvent[6];
Then create a windows thread, etc..ugh. Too confusing for me
at the moment.
Scruff