Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

grinder

DirectSound

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

Create a notification event that sets a flag when the wave file is done playing. During your main loop, just check the status of the flag and flip pages if needed.

Jim

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I don't think DirectX provides you with any way to let you
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Oh, I forgot to mention that the above method is not really
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

Share this post


Link to post
Share on other sites
DirectSound notifications, when correctly setup, WILL notify you when a sound is finished playing. That's one of the reasons for them. It will work with static and streaming buffers, and very easily at that. Here's how:

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

Share this post


Link to post
Share on other sites
Actually Direct Sound does have this capability. Read up on:

IDirectSoundNotify::SetNotificationPositions()

Works like a hot-damn.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Sure, I don't mind reading a tutorial on DirectSound notifications.

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

Share this post


Link to post
Share on other sites
I'm currently working on an interactive storybook. I have a voice reading the text and when the wav file end I want the page to flip.
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_

------------------

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Oops, step (1), you know what I mean

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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!