PLAYWAV statement

Purpose: PLAYWAV plays the sound contained in a .wav soundfile.


 Syntax 1:

 PLAYWAV(SoundFile$ [, ,SoundFlags])

 Parameters:

  • Soundfile$ is the name of sound file to be played.
  • SoundFlags [OPTIONAL] Please note that if this option is used it must be preceded by a NULL argument specified simply with a comma. This parameter is for flags specifying the sound event characteristics. For example, if SoundFlags was set to SND_SYNC then PLAYWAV would wait to return until after playing the .wav but if SoundFlags was set to SND_ASYNC then the PLAYWAV function would return immediately.

    Other valid flags may be combined with the BOR operator. See the fdwSound parameter in the PlaySound function section of your Win32 SDK or PSDK Reference help for more information about valid SoundFlags arguments.


 Syntax 2:

 PLAYWAV("", Resource_ID% [,SoundFlags])

 Parameters:

  • "" an empty string indicating that the .wav is not being loaded from a file.
  • Resource_ID% is an integer resource argument. The resource file(.rc) should be setup as:
    
     Resource_ID% RCDATA "filename.wav"
    
    
    RCDATA is a resource-definition statement specifying a raw data resource allowing the inclusion of binary data in the executable file.
  • SoundFlags [OPTIONAL] This parameter is for flags specifying the sound event characteristics. For example, if SoundFlags was set to SND_SYNC then PLAYWAV would wait to return until after playing the .wav but if SoundFlags was set to SND_ASYNC then the PLAYWAV function would return immediately.

    Other valid flags may be combined with the BOR operator. See the fdwSound parameter in the PlaySound function section of your Win32 SDK or PSDK Reference help for more information about valid SoundFlags arguments.

Example:


 
 $RESOURCE "$PELLES$\bin\porc.exe"
  
 $COMPILER "$PELLES$\Bin\pocc -W1 -Gd -Go -Ze -Zx -Tx86-coff $FILE$.c"
  
 $LINKER "$PELLES$\Bin\polink _
                     -release _
                -machine:ix86 _
           -subsystem:console _
              -OUT:$FILE$.exe _
                   $FILE$.obj "
  
 BCX_RESOURCE 1234 RCDATA "C:\Windows\Media\Windows XP Startup.wav"
 
 PLAYWAV("", 1234)

BCX Console Sample Programs using PLAYWAV statement.

S68.bas

Here is an alternative to the PLAYWAV statement. This example can play a .mid file and .wav file at the same time. With modifications, the program can play two .wav files at the same time. However, it can not play two .mid files at the same time. This demo uses the .mid and .wav files from the GUI_Demo\Breakout game. You may have to adjust the paths in the FileName1$ and FileName2$ variables. Run the demo, click on the Start button and then click on the Overlay button and you will hear the .wav voice superimposed on the .mid music.


 GUI "PlayMT"
   
 $LIBRARY <winmm.lib>
   
 GLOBAL Form1   AS HWND
 GLOBAL Button1 AS HWND
 GLOBAL Button2 AS HWND
 GLOBAL FileName1$
 GLOBAL FileName2$
 GLOBAL RetStr$
   
 CONST ID_Button1 = 101
 CONST ID_Button2 = 102
   
 SUB FORMLOAD
   
   Form1 = BCX_FORM("Play Multi-Thread", 0, 0, 120, 30)
   
   Button1 = BCX_BUTTON("Start", Form1, ID_Button1, 10, 5, 45, 16)
   Button2 = BCX_BUTTON("Overlay", Form1, ID_Button2, 60, 5, 45, 16)
   
   FileName1$ = BCXPATH$ & "..\GUI_Demo\Breakout\Splash.mid"
   FileName2$ = BCXPATH$ & "..\GUI_Demo\Breakout\Level.wav"
 
   mciSendString("open " & CHR$(34) & FileName1$ & CHR$(34) & " alias mid1", RetStr$, 255, Form1)
   mciSendString("open " & CHR$(34) & FileName2$ & CHR$(34) & " alias wav2", RetStr$, 255, Form1)
   
   SHOW (Form1) ' Show it!
   
 END SUB
   
   
 BEGIN EVENTS
   SELECT CASE CBMSG
   
   CASE WM_CREATE
   
     EXIT FUNCTION
   
   CASE WM_COMMAND
     IF CBCTL = ID_Button1 THEN
       mciSendString("seek mid1 to start", RetStr$, 255, Form1)
   
       mciSendString("play mid1", RetStr$, 255, Form1)
       EXIT FUNCTION
     END IF
   
     IF CBCTL = ID_Button2 THEN
       mciSendString("seek wav2 to start", RetStr$, 255, Form1)
       mciSendString("play wav2", RetStr$, 255, Form1)
       EXIT FUNCTION
     END IF
   
   CASE WM_CLOSE
     mciSendString("close all", RetStr$, 255, Form1)
     DestroyWindow (Form1)
     EXIT FUNCTION
   END SELECT
   
 END EVENTS