dcsimg
Results 1 to 5 of 5

Thread: DirectSound - how to tell if a sound is playing?

  1. #1

    Thread Starter
    New Member Son of Makuta's Avatar
    Join Date
    Sep 2007
    Posts
    14

    DirectSound - how to tell if a sound is playing?

    Hi
    Can someone tell me how to test if a sound (DirectSoundSecondaryBuffer8 object... what a name) is playing in DirectSound? I've tried using something like

    If Sound.GetCurrentPosition <> 0 Then

    but GetCurrentPosition needs some weird argument - cursors As DSCURSORS - which I've never heard of, don't understand, and can't find on Google.

    Also, there doesn't seem to be a Sound.IsPlaying function or anything like that.

    Can anyone offer me some enlightenment please?

  2. #2
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: DirectSound - how to tell if a sound is playing?

    You'd probably create a class that would play sounds for you and keep tracking of the currently playing sound in the class. I'm thinking enums.

  3. #3

    Thread Starter
    New Member Son of Makuta's Avatar
    Join Date
    Sep 2007
    Posts
    14

    Re: DirectSound - how to tell if a sound is playing?

    I've got a class, but there's no way to keep track of what's playing without using this, as I don't know of a way to find out how long the sounds are either :/

  4. #4
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: DirectSound - how to tell if a sound is playing?

    If your using wave files, then it's very easy to calculate the sound length.

    Also, there is a way to put events through the buffer, so you can put an event right at the end of the buffer, so it will raise an event when the sound is done playing.

    You should post the code you have so I can have a better idea of what you are doing.

  5. #5
    Hyperactive Member metalmidget's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    342

    Re: DirectSound - how to tell if a sound is playing?

    Quote Originally Posted by Son of Makuta
    but GetCurrentPosition needs some weird argument - cursors As DSCURSORS - which I've never heard of, don't understand, and can't find on Google.
    Don't use google. Use the SDK documentation, which for me is located at <DXSDKPath>\Documentation\DirectX9\directx_sdk.chm. The documentation is excellent, and you should be able to figure out heaps of functions, datatypes, etc etc just by looking it up there.
    According to the SDK documentation, the parameters for the function IDirectSoundBuffer8::GetCurrentPosition are:

    pdwCurrentPlayCursor
    Address of a variable that receives the offset, in bytes, of the play cursor. This parameter can be NULL if the value is not wanted.
    pdwCurrentWriteCursor
    Address of a variable that receives the offset, in bytes, of the write cursor. This parameter can be NULL if the value is not wanted.

    According to what I've got here, the type of the variables is LPDWORD. If you're not sure about a Win32 datatype, look it up at MSDN and you should be fine. Also, you could try looking up IDirectSoundBuffer8 in the documentation and you'll find a list of all the methods and a brief description, with links to details

    metal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width