Announcement

Collapse
No announcement yet.

Wave sound in resource file

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

  • Scott Turchin
    replied
    I have found if you use a #define it will not work, not sure why, don't care really cuz it works as is...

    Also note, I *THINK* location of the wav file matters also, needs to be in the directory (had issues with that)..
    And, if you have icons also in the resource and are being defined, do all those first and the WAVE Files last.....seems to matter..


    Or send me the code and wav and I'll take a gander at it..

    Scott


    ------------------
    Scott
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Kerry_Goodin
    Guest replied
    Thanks Scott but I still cannot get it to work. here is what I have:
    Code:
    [i]in the resourc file:[/i]
    IDR_WAVE1               WAVE    DISCARDABLE     "Sound.wav"
    
    [i]in the .bas file:[/i]
    LOCAL g_Result       AS LONG 
    CASE %WM_INITDIALOG
                  g_Result = PlayWavFromResource(BYCOPY ghInst, "IDR_WAVE1", "WAVE")
                  
    [i]in the .inc file:[/i]
    FUNCTION PlayWavFromResource(hInstance AS LONG, WaveName AS STRING, WaveType AS STRING)AS LONG
        LOCAL hRes AS LONG
        LOCAL lpWav AS BYTE PTR
        LOCAL Wave1 AS ASCIIZ * 10
        LOCAL Wav1 AS ASCIIZ * 10
        Wave1 = WaveName
        Wav1 = WaveType
        hRes = FindResource (hInstance, Wave1, Wav1)
        IF hRes THEN
            lpWav = LockResource (LoadResource (hInstance, hRes))
            IF lpWav THEN FUNCTION = PlaySound(BYVAL lpWav, hInstance, %SND_MEMORY OR %SND_ASYNC)
        END IF
    END FUNCTION
    What am I missing. I still have no sound. I have the resource compiled into the .pbr.
    Kerry


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

    Leave a comment:


  • Kerry_Goodin
    Guest replied
    duplicate message deleted by K. Goodin



    [This message has been edited by Kerry_Goodin (edited October 06, 2000).]

    Leave a comment:


  • Scott Turchin
    replied
    Here's how I do mine:

    RESOURCE FILE:
    '
    'Does not seem to require a #define statement (??)

    WAVE1 WAV01 "AIRNUKE.WAV"
    WAVE2 WAV02 "PING.WAV"
    WAVE3 WAV03 "RESPONSE.WAV"


    '

    PBDLL .BAS FILE:

    Declare Function PlayWavFromResource(hInstance As Long, WaveName As String, WaveType As String)As Long

    'To use:
    WAV = "WAV"
    g_Result = PlayWavFromResource(g_hInst,WAVE + "2",WAV + "02")

    '
    '
    '
    Function PlayWavFromResource(hInstance As Long, WaveName As String, WaveType As String)As Long
    'Function PlayWavFromResource(hInstance As Long, WaveName As Asciiz, WaveType As Asciiz)As Long
    Local hRes As Long
    Local lpWav As Byte Ptr
    Local Wave1 As Asciiz * 10
    Local Wav1 As Asciiz * 10
    Wave1 = WaveName
    Wav1 = WaveType
    hRes = FindResource (hInstance, Wave1, Wav1)
    If hRes Then
    lpWav = LockResource (LoadResource (hInstance, hRes))
    If lpWav Then Function = PlaySound(ByVal lpWav, hInstance, %SND_MEMORY Or %SND_ASYNC)
    End If
    End Function


    ------------------
    Scott
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Phil Tippit
    replied
    kerry,
    http://www.powerbasic.com/support/pb...ead.php?t=2678

    phil

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

    Leave a comment:


  • Lance Edmonds
    replied
    IIRC, you need to use %SND_RESOURCE (I'm not at my DEV PC to check the API constant names ). Regardless, a search of the BBS for "playsound" or "sndplaysound" should help here...

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

    Leave a comment:


  • Kerry_Goodin
    Guest started a topic Wave sound in resource file

    Wave sound in resource file

    I have added a wave file to my resource file and compile to a .res.
    I have used:

    FUNCTION = PlaySound("mywave.wav", BYCOPY 0, %SND_MEMORY)

    to play the file in the same directory but I want to include it in the file now.

    my program was generated by PowerGen and it uses the include file that was generated.

    here is what I have so far:

    FUNCTION PlayWav(BYVAL hDlg AS LONG) AS LONG
    LOCAL hRes AS LONG
    LOCAL lpWav AS BYTE PTR
    LOCAL hInst AS LONG
    FUNCTION = PlaySound("mywave.wav", BYCOPY 0, %SND_MEMORY) 'plays a file
    END FUNCTION

    With the wave resource being named "WAVE"
    and the id "%IDR_WAVE1".

    How do I find the resource and then make PlaySound use it?

    Kerry


    ------------------
Working...
X
😀
🥰
🤢
😎
😡
👍
👎