Announcement

Collapse
No announcement yet.

Playsound and .RC options to play two or more .Wav files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mike Trader
    replied
    Thx lance.

    For those following this thread the new version of PBRES is at: http://www.powerbasic.com/files/pub/pbwin/
    The bug is fixed. Multiple Wavs play fine

    ------------------
    Kind Regards
    Mike

    Leave a comment:


  • Lance Edmonds
    replied
    Really? Your code is almost completely API code, so it looks much more likely that you are actually having API problems.

    Please note that there was an update to PBRES some months ago which was designed to cure a problem where some resource types could not be loaded from the resource file, especially when the PBR included multiple WAV files.

    You may want to make sure you are using the latest version of PBRES, which can be obtained from the DOWNLOADS section.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Mike Trader
    replied
    OK I got you. Ill use sndPLaySound() instead.

    I think we have found a PB bug! - Lance ...

    ------------------
    Kind Regards
    Mike

    Leave a comment:


  • Jules Marchildon
    replied
    Mike--

    Yes, that is correct, using the Find,lock,Play,unlock method works
    like yours. The PlaySound() api call does not. BTW, if you use the
    find-lock-play-unlock method you should use sndPlaySound() api not the
    Playsound(), since Playsound() does that for you otherwise you are
    really doing a "find-lock-play-unlock" twice. I am still convinced that
    a parameter being passed by the PB PlaySound() api conversion is wrong,
    I just have not figured which one yet...

    ---Jules

    Leave a comment:


  • Mike Trader
    replied
    Jules,

    Are you saying this does not work for you...

    This does work: (plays 2 .wav files)
    #COMPILE EXE "PlayRc.exe"
    #INCLUDE "WIN32API.INC"
    #RESOURCE "Sound.PBR"

    'sound.rc
    'DING RCDATA DING.WAV
    'BITE RCDATA BITE.WAV

    FUNCTION PBMAIN() AS LONG

    LOCAL lpWav AS BYTE PTR
    hInst&=GetModuleHandle("")
    hRes& = FindResource(hInst&,"DING",BYVAL %RT_RCDATA)
    lpWav = LockResource(LoadResource(hInst&, hRes&))
    CALL PlaySound(BYVAL lpWav,hInst&,%SND_MEMORY OR %SND_ASYNC)
    FreeResource hRes&
    MSGBOX "done"

    hInst&=GetModuleHandle("")
    hRes& = FindResource(hInst&,"BITE",BYVAL %RT_RCDATA)
    lpWav = LockResource(LoadResource(hInst&, hRes&))
    CALL PlaySound(BYVAL lpWav,hInst&,%SND_MEMORY OR %SND_ASYNC)
    FreeResource hRes&
    MSGBOX "done"

    END FUNCTION

    Are you compiling the resource ok?
    This works for me but it cumbersome. The other method is alot slicker and should work!



    ------------------
    Kind Regards
    Mike

    Leave a comment:


  • Jules Marchildon
    replied
    Sorry Mike,

    I tried your tests examples and also read all the posts. About
    a month ago I was trying to use your method two, but to no avail
    could not find a reason why it would not work.

    I used similar code to your first example and also used code to play
    waves from file for now.

    This is still a mystery...

    Regards,
    Jules

    Oh! And this interesting note, PlaySound() is a wrapper for the
    sndPlaySound() function, that is it does the "find, load, lock, unlock,
    and free the resource". So just maybe, the parameters passed by the
    PB version of the api PlaySound() function could be wrong since your
    first example works.



    [This message has been edited by Jules Marchildon (edited June 15, 2001).]

    Leave a comment:


  • Mike Trader
    replied
    Oops the .RC file for the second example (the one that does play two sound files, should be:
    'sound.rc
    'DING RCDATA DING.WAV
    'BITE RCDATA BITE.WAV

    ------------------
    Kind Regards
    Mike

    Leave a comment:


  • Playsound and .RC options to play two or more .Wav files

    This is a subject i have been getting to for a long time.
    I have read Poffs over and over on the subject. I have written about 10 examples and tried every combination and permutation you can think of. I have tried Names, Numbers etc etc to make sure i have not missed anything.

    This works:
    #COMPILE EXE "PlayRc.exe"
    #INCLUDE "WIN32API.INC"
    #RESOURCE "Sound.PBR"

    'sound.rc
    'DING SOUND DING.WAV

    FUNCTION PBMAIN
    PlaySound "DING", BYVAL GetModuleHandle(BYVAL %NULL), %SND_RESOURCE OR %SND_SYNC
    MSGBOX "done"
    END FUNCTION

    This does work: (plays 2 .wav files)
    #COMPILE EXE "PlayRc.exe"
    #INCLUDE "WIN32API.INC"
    #RESOURCE "Sound.PBR"

    'sound.rc
    'DING SOUND DING.WAV
    'BITE SOUND BITE.WAV

    FUNCTION PBMAIN() AS LONG

    LOCAL lpWav AS BYTE PTR
    hInst&=GetModuleHandle("")
    hRes& = FindResource(hInst&,"DING",BYVAL %RT_RCDATA)
    lpWav = LockResource(LoadResource(hInst&, hRes&))
    CALL PlaySound(BYVAL lpWav,hInst&,%SND_MEMORY OR %SND_ASYNC)
    FreeResource hRes&
    MSGBOX "done"

    hInst&=GetModuleHandle("")
    hRes& = FindResource(hInst&,"BITE",BYVAL %RT_RCDATA)
    lpWav = LockResource(LoadResource(hInst&, hRes&))
    CALL PlaySound(BYVAL lpWav,hInst&,%SND_MEMORY OR %SND_ASYNC)
    FreeResource hRes&
    MSGBOX "done"

    END FUNCTION

    This Does Not Work: (it will not play the second .wav but NOT the first)
    #COMPILE EXE "PlayRc.exe"
    #INCLUDE "WIN32API.INC"
    #RESOURCE "Sound.PBR"

    'sound.rc
    'DING SOUND DING.WAV
    'BITE SOUND BITE.WAV

    FUNCTION PBMAIN
    PlaySound "DING", BYVAL GetModuleHandle(BYVAL %NULL), %SND_RESOURCE OR %SND_SYNC
    PlaySound "BITE", BYVAL GetModuleHandle(BYVAL %NULL), %SND_RESOURCE OR %SND_SYNC
    MSGBOX "done"
    END FUNCTION


    Why doesnt this work?

    ------------------
    Kind Regards
    Mike
Working...
X