Announcement

Collapse
No announcement yet.

Wave sound in resource file

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

  • 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


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

  • #2
    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>
    Lance
    mailto:[email protected]

    Comment


    • #3
      kerry,
      http://www.powerbasic.com/support/pb...ead.php?t=2678

      phil

      ------------------
      E-Mail:
      pt AT pursuersoft DOT com

      Comment


      • #4
        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>
        Scott Turchin
        MCSE, MCP+I
        http://www.tngbbs.com
        ----------------------
        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

        Comment


        • #5
          duplicate message deleted by K. Goodin



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

          Comment


          • #6
            Thanks Scott but I still cannot get it to work. here is what I have:
            Code:
            in the resourc file:
            IDR_WAVE1               WAVE    DISCARDABLE     "Sound.wav"
            
            in the .bas file:
            LOCAL g_Result       AS LONG 
            CASE %WM_INITDIALOG
                          g_Result = PlayWavFromResource(BYCOPY ghInst, "IDR_WAVE1", "WAVE")
                          
            in the .inc file:
            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


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

            Comment


            • #7
              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>
              Scott Turchin
              MCSE, MCP+I
              http://www.tngbbs.com
              ----------------------
              True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

              Comment

              Working...
              X