Jump to content

  • Log In with Google      Sign In   
  • Create Account


DirectSound


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 grinder   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 October 1999 - 07:13 PM

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_

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


Sponsor:

#2 Jim Adams   Members   -  Reputation: 440

Like
Likes
Like

Posted 07 October 1999 - 06:04 AM

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


#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 07 October 1999 - 01:11 PM

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


#4 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 07 October 1999 - 01:22 PM

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


#5 Jim Adams   Members   -  Reputation: 440

Like
Likes
Like

Posted 07 October 1999 - 02:48 PM

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


#6 Sphet   Members   -  Reputation: 631

Like
Likes
Like

Posted 07 October 1999 - 02:49 PM

Actually Direct Sound does have this capability. Read up on:

IDirectSoundNotify::SetNotificationPositions()

Works like a hot-damn.


#7 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 07 October 1999 - 07:07 PM

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


#8 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 07 October 1999 - 07:13 PM

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





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS