Announcement

Collapse
No announcement yet.

RC and PBR File Problems

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

  • RC and PBR File Problems

    Need some help!

    I first created a RC file with the following:

    201 WAVE "c:\pbdll60\sundgolf\sevniron.wav"

    at dos prompt I did:
    rc wavegolf.rc
    pbres wavegolf.res
    Code:
    $COMPILE EXE
    $REGISTER NONE
    $DIM ALL
    #RESOURCE "wavegolf.pbr"
    $INCLUDE "win32api.inc"
    ' i& and lresult& have been dimmed
    
              'within the program  
            for i&=201 TO 201
              lresult& = SndPlaySound("#"+TRIM$(STR$(i&)), %SND_RESOURCE OR %SND_ASYNC )
              MSGBOX "Playing"
            NEXT
    
    The wave sevniron.wav plays as it should, its Kevin Costner
    in Tin Cup; "Well, there is always the seven iron."
    
    Then I created a RC File with all the following wave files
    and created the Pbr file.
    
    201 WAVE "c:\pbdll60\sundgolf\sevniron.wav"
    202 WAVE "c:\pbdll60\sundgolf\holeone.wav"
    203 WAVE "c:\pbdll60\sundgolf\fiveiron.wav"
    204 WAVE "c:\pbdll60\sundgolf\getnhole.wav"
    205 WAVE "c:\pbdll60\sundgolf\klmostin.wav"
    206 WAVE "c:\pbdll60\sundgolf\knother.wav"
    207 WAVE "c:\pbdll60\sundgolf\puterror.wav"
    208 WAVE "c:\pbdll60\sundgolf\bfuldrv.wav"
    209 WAVE "c:\pbdll60\sundgolf\bottom.wav"
    210 WAVE "c:\pbdll60\sundgolf\cantplay.wav"
    211 WAVE "c:\pbdll60\sundgolf\closer.wav"
    212 WAVE "c:\pbdll60\sundgolf\comments.wav"
    213 WAVE "c:\pbdll60\sundgolf\damalloy.wav"
    214 WAVE "c:\pbdll60\sundgolf\dammit.wav"
    215 WAVE "c:\pbdll60\sundgolf\gretputt.wav"
    216 WAVE "c:\pbdll60\sundgolf\deepstuf.wav"
    217 WAVE "c:\pbdll60\sundgolf\dessert.wav"
    218 WAVE "c:\pbdll60\sundgolf\difficlt.wav"
    219 WAVE "c:\pbdll60\sundgolf\driver.wav"
    220 WAVE "c:\pbdll60\sundgolf\espn.wav"
    221 WAVE "c:\pbdll60\sundgolf\kybetter.wav"
    222 WAVE "c:\pbdll60\sundgolf\fcrushed.wav"
    223 WAVE "c:\pbdll60\sundgolf\fdeep.wav"
    224 WAVE "c:\pbdll60\sundgolf\fg.wav"
    225 WAVE "c:\pbdll60\sundgolf\finwater.wav"
    226 WAVE "c:\pbdll60\sundgolf\fancshot.wav"
    227 WAVE "c:\pbdll60\sundgolf\fore.wav"
    228 WAVE "c:\pbdll60\sundgolf\gbird.wav"
    229 WAVE "c:\pbdll60\sundgolf\getin.wav"
    230 WAVE "c:\pbdll60\sundgolf\whatdoin.wav"
    231 WAVE "c:\pbdll60\sundgolf\goin.wav"
    232 WAVE "c:\pbdll60\sundgolf\goodsave.wav"
    233 WAVE "c:\pbdll60\sundgolf\gramps.wav"
    234 WAVE "c:\pbdll60\sundgolf\hateit.wav"
    235 WAVE "c:\pbdll60\sundgolf\headdown.wav"
    236 WAVE "c:\pbdll60\sundgolf\heybud.wav"
    237 WAVE "c:\pbdll60\sundgolf\hitech.wav"
    238 WAVE "c:\pbdll60\sundgolf\ho.wav"
    239 WAVE "c:\pbdll60\sundgolf\humble.wav"
    240 WAVE "c:\pbdll60\sundgolf\hurry.wav"
    241 WAVE "c:\pbdll60\sundgolf\knowall.wav"
    242 WAVE "c:\pbdll60\sundgolf\magbast.wav"
    243 WAVE "c:\pbdll60\sundgolf\spfkdup.wav"
    244 WAVE "c:\pbdll60\sundgolf\spslut.wav"
    245 WAVE "c:\pbdll60\sundgolf\vanished.wav"
    246 WAVE "c:\pbdll60\sundgolf\goodball.wav" 
    
            for i&=201 TO 201   ' 245
              lresult& = SndPlaySound("#"+TRIM$(STR$(i&)), %SND_RESOURCE OR %SND_ASYNC)
              ' note PlaySound also has the same problem.
              MSGBOX "Playing"
            NEXT
    
    It will not even play 201, less any of the others.
    
    I can create a RC file with any of the sounds with only one
    of them and it will play correctly.
    
    What is the problem???.  What I'm doing wrong, is there other
    code I should be using???
    
    Also another note:
    
    The following files original names started with 
    the letter a    almostin.wav, etc.
    
    202 WAVE "c:\pbdll60\sundgolf\holeone.wav"
        the 202 file originally was ace.wav until I renamed it 
        holeone.wav
    205 WAVE "c:\pbdll60\sundgolf\klmostin.wav"
    206 WAVE "c:\pbdll60\sundgolf\knother.wav"
    221 WAVE "c:\pbdll60\sundgolf\kybetter.wav"
    
    RC.exe would return an error that the file was not found.
    
    It seems that RC.exe does not like file names starting with
    the letter a. In the error message it displayed the following
    file path and name:  
    
    "c:\pbdll60\sundgolfybetter.wav" instead of
    "c:\pbdll60\sundgolf\aybetter.wav"
    Once I renamed them it would compile the RES file.

    Any feedback would be appreciated,

    Phil

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


    [This message has been edited by Phil Tippit (edited September 08, 2000).]
    E-Mail:
    pt AT pursuersoft DOT com

  • #2
    I have the same trouble with some of my filenames.

    It looks stupid but i solved it this way:

    file1 RCDATA "C:\\PATH\\PROGRAM.EXE"

    It depends on slashes (like c)
    This is because you used ""
    Without them you will encounter other problems


    ------------------
    [email protected]
    hellobasic

    Comment


    • #3
      You have to use PlaySound(...) and not SndPlaySound(...) to play a wave-file from a resource
      %SND_RESOURCE is not a valid flag in SndPlaySound.... (according to MSDN)
      Code:
      RC-FILE  "WAV.RC"
        START  WAVE "c:\Windows\media\start.wav"
        CHIMES WAVE "c:\Windows\media\chimes.wav"
        CHORD  WAVE "c:\Windows\media\chord.wav"
        201    WAVE "c:\Windows\media\start.wav"
        202    WAVE "c:\Windows\media\chimes.wav"
        203    WAVE "c:\Windows\media\chord.wav"
      
      ----------------------   
      PBCC-PROGRAM
         
      #Resource "WAV.PBR"
      #Include "win32api.inc"
      Function PbMain()As Long
         Call PlaySound("START",ByVal GetModuleHandle(ByVal %NULL),%SND_RESOURCE Or %SND_SYNC)
         Call PlaySound("CHIMES",ByVal GetModuleHandle(ByVal %NULL),%SND_RESOURCE Or %SND_SYNC)
         Call PlaySound("CHORD",ByVal GetModuleHandle(ByVal %NULL),%SND_RESOURCE Or %SND_SYNC)
         Call PlaySound(ByVal MakDwd(201,0),ByVal GetModuleHandle(ByVal %NULL),%SND_RESOURCE Or %SND_SYNC)
         Call PlaySound(ByVal MakDwd(202,0),ByVal GetModuleHandle(ByVal %NULL),%SND_RESOURCE Or %SND_SYNC)
         Call PlaySound(ByVal MakDwd(203,0),ByVal GetModuleHandle(ByVal %NULL),%SND_RESOURCE Or %SND_SYNC)
         waitkey$
      End Function
      ------------------
      Fred
      mailto:[email protected][email protected]</A>
      http://www.oxenby.se


      [This message has been edited by Fred Oxenby (edited September 12, 2000).]
      Fred
      mailto:[email protected][email protected]</A>
      http://www.oxenby.se

      Comment


      • #4
        Fred,

        I tried your example using two of my own WAV files and with PBDLL6.0 and I've only been able to get one to play. I seem to be running into the same problem as the user who started this topic. Only the second file worked in the two file case and, in fact, only the second file worked in a 5 WAV files trial! I wonder how I might get to the bottom of this?

        Comment


        • #5
          All,

          My prior post was wrong. It's always the last file that plays and I don't know why

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

          Comment


          • #6
            All,

            Hot of the press! In order to get multiple WAV entries to play
            I did the following:

            Use Fred's example above to set up the RC file and instead of
            using SND_RESOURCE, use SND_APPLICATION. I believe this works
            because we are using a user-defined Resource-Definition statement
            and this defines a resource with application specific data. Thus,
            the corresponding flag for a application specific association
            is SND_APPLICATION and not SND_RESOURCE.

            Hope this helps!

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

            Comment


            • #7
              same problem with pbr-file seems to apply here as described in this thread?
              (according to my tests this is the case)
              http://www.powerbasic.com/support/pb...ead.php?t=2651
              what i do is:
              1) create the the res-file via a rc-script
              2) not using the #resource metastetment in the code
              3) use rsrc.exe (supplied by jcfuller) and embedd the resource in the exefile
              4) use %snd_sync so the sound is ended before trying to start a second sound
              5) use %snd_resource because that is (i think),the correct one
              and believe it or not, it is working on win98,win2000me,win2000pro
              if it cannot find the specified sound, playsound uses the default system event sound entry instead.
              if the function can find neither the system default entry nor the default sound, it makes no sound and returns false.
              >> c.m.rouleau
              >> my prior post was wrong. it's always the last file that plays and i don't know why
              this is becase your last entry will be the first entry in the resource (lastinfirstout)
              and omly the first entry wil be found..
              ------------------
              fred
              mailto:[email protected][email protected]</a>
              http://www.oxenby.se


              [this message has been edited by fred oxenby (edited september 12, 2000).]
              Fred
              mailto:[email protected][email protected]</A>
              http://www.oxenby.se

              Comment


              • #8
                Originally posted by C.M. Rouleau:
                Use Fred's example above to set up the RC file and instead of
                using SND_RESOURCE, use SND_APPLICATION. I believe this works
                because we are using a user-defined Resource-Definition statement
                and this defines a resource with application specific data. Thus,
                the corresponding flag for a application specific association
                is SND_APPLICATION and not SND_RESOURCE.
                Code:
                  Three flags in fdwSound (SND_ALIAS, SND_FILENAME, and SND_RESOURCE) 
                  determine whether the name is interpreted as an alias for 
                  a system event, a filename, or a resource identifier. 
                  If none of these flags are specified, PlaySound searches the registry 
                  or the WIN.INI file for an association with the specified sound name. 
                  If an association is found, the sound event is played.
                  
                  If no association is found in the registry, the name is interpreted as a filename. 
                Specifying %SND_APPLICATION you are obviosly not playing from a resource.
                However if your RESOURCEID = NAME of a WAV-file in your path this will be played
                Try it without any PBR-file at all...



                ------------------
                Fred
                mailto:[email protected][email protected]</A>
                http://www.oxenby.se

                Fred
                mailto:[email protected][email protected]</A>
                http://www.oxenby.se

                Comment


                • #9
                  Fred,

                  You were right on the above - I had the ID and filename named
                  the same and that's what got my hopes up. So what is the underlying
                  reason for the failure of rc and pbres to compile a usable resource
                  iin the case of WAVs?

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

                  Comment


                  • #10
                    Same reason as for AVI-resources mentioned in another thread


                    ------------------
                    Fred
                    mailto:[email protected][email protected]</A>
                    http://www.oxenby.se



                    [This message has been edited by Fred Oxenby (edited September 12, 2000).]
                    Fred
                    mailto:[email protected][email protected]</A>
                    http://www.oxenby.se

                    Comment


                    • #11
                      Fellows,

                      Try this on for size, I now have it working with over 200
                      wave files defined in a rc-res-pbr resource file.


                      Code:
                      'PBDLL60
                      #COMPILE EXE
                      #DIM ALL
                      #RESOURCE "samplerc.pbr"
                         ' this is the script in samplerc.rc
                         ' edit the file names and descriptions for
                         ' some waves files that you have on your system
                      '201 RCDATA "c:\pbdll60\sundgolf\sevniron.wav"
                      '202 RCDATA "c:\pbdll60\sundgolf\holeone.wav"
                      '203 RCDATA "c:\pbdll60\sundgolf\getnhole.wav"
                      '204 RCDATA "c:\pbdll60\sundgolf\klmostin.wav"
                      '205 RCDATA "c:\pbdll60\sundgolf\knother.wav"
                      'STRINGTABLE
                      'BEGIN
                      ' 501 "There's Always The Seven Iron"
                      ' 502 "Thrill of a Hole-In-One"
                      ' 503 "Get In The Hole"
                      ' 504 "Almost In The Hole"
                      ' 505 "Hope You Have Another Ball"
                      'END
                      
                      
                      #INCLUDE "win32api.INC"
                      GLOBAL hCurInstance AS LONG
                      CALLBACK FUNCTION BtnCallback
                          LOCAL Result1&, Result2&
                          LOCAL hRes AS LONG
                          LOCAL lpWav AS BYTE PTR
                          IF CBCTL = %IDOK THEN
                              CONTROL SEND CBHNDL, 100, %LB_GETCURSEL, 0, 0 TO Result1&
                              IF Result1& >= 0 THEN
                                 Result1&=Result1&+201
                                 hRes = FindResource (hCurInstance, BYVAL Result1&, BYVAL %RT_RCDATA)
                                 IF hRes THEN
                                   lpWav = LockResource (LoadResource (hCurInstance, hRes))
                                   DIALOG DOEVENTS
                                   IF lpWav THEN
                                     FUNCTION = PlaySound(BYVAL lpWav, hCurInstance, %SND_MEMORY OR %SND_SYNC)
                                   END IF
                                   DIALOG DOEVENTS
                                   FreeResource hRes
                                 END IF
                              END IF
                      
                          ELSE
                              DIALOG END CBHNDL, 0
                          END IF
                      END FUNCTION
                      
                      CALLBACK FUNCTION DlgCallback
                          ' Handle double click messages by pushing the OK button
                          IF CBCTL = 100 AND CBCTLMSG = %LBN_DBLCLK THEN
                              CONTROL SEND CBHNDL, %IDOK, %BM_CLICK, 0, 0
                          END IF
                      END FUNCTION
                      
                      FUNCTION WINMAIN (BYVAL hInstance  AS LONG, _
                                        BYVAL hPrevInstance AS LONG, _
                                        lpszCmdLine         AS ASCIIZ PTR, _
                                        BYVAL nCmdShow      AS LONG) AS LONG
                          hCurInstance=hInstance
                          DIM lpbuffer AS ASCIIZ * 40
                          DIM strp AS STRING PTR,nBufferMax&,y&
                          DIM x&, hDlg&, a$()
                          strp = VARPTR(lpbuffer$):nBufferMax&=40
                          DIM a$(1:5)
                          FOR x& = 501 TO 505
                              y&=LoadString (BYVAL hInstance, BYVAL x&, lpBuffer , BYVAL nBufferMax)
                              IF y& > 0 THEN
                                 a$(x&-500) = LEFT$(lpbuffer$,y&)
                              ELSE
                                 a$(x&-500)="ITEM "+STR$(x&-500)
                              END IF
                          NEXT x&
                      
                          DIALOG NEW 0,"ListBox Example",,,530,320,%WS_SYSMENU OR %WS_THICKFRAME OR %DS_CENTER, TO hDlg
                          CONTROL ADD BUTTON, hDlg, %IDOK, "&Ok", 10,185,40,14, %BS_DEFAULT OR %WS_TABSTOP CALL BtnCallback
                          CONTROL ADD BUTTON, hDlg, %IDCANCEL, "&Cancel", 100,185,40,14 CALL BtnCallback
                      
                          CONTROL ADD LISTBOX, hDlg, 100, a$(), 10, 10, 180, 175, %LBS_DISABLENOSCROLL OR %WS_TABSTOP OR %LBS_NOTIFY OR %WS_VSCROLL, %WS_EX_CLIENTEDGE
                          DIALOG SHOW MODAL hDlg CALL DlgCallback
                      END FUNCTION
                      ------------------
                      E-Mail:
                      pt AT pursuersoft DOT com

                      Comment


                      • #12
                        Phil,

                        Yes! You're onto something. I tried the following and it worked
                        also. No need for the stringable stuff.

                        sound.rc file
                        howdy rcdata welcome.wav
                        bubye rcdata bye.wav

                        #COMPILE EXE
                        #RESOURCE "sound.pbr"
                        #INCLUDE "WIN32API.INC"

                        FUNCTION PBMAIN() AS LONG

                        LOCAL lpWav AS BYTE PTR

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

                        DIALOG NEW 0,"Sound Demo",,,200,100,0,0 TO hDlg&
                        DIALOG SHOW MODAL hDlg&

                        END FUNCTION

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

                        Comment


                        • #13
                          Phil, Edwin and Fred... can you please contact me directly by email... Thanks!



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

                          Comment

                          Working...
                          X