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.

  
 'The old 16bit MCI drivers have the downside of
 'not being multi-threaded and hence you can only play
 'one sound at a time or you get the mmsystem device in use
 'dialog thrown up.
 '
 'Well, We do have one 32bit multi-threaded MCI driver in the
 'default windows install and thats the mciqtz.drv of ActiveMovie.
 'ActiveMovie plays all the standard filetypes covered in the older
 'mci drivers and is perfectly compatible.
 '
 'So just comment out the older drivers in system.ini and
 'add new lines assigning them to mciqtz.drv and you can
 'now play multiple sounds simultaneously.
 '
 '[mci]
 'cdaudio=mcicda.drv
 'avivideo=mciavi.drv
 ';sequencer=mciseq.drv
 'sequencer=mciqtz.drv
 ';waveaudio=mciwave.drv
 'waveaudio=mciqtz.drv
 'MPEGVideo2=mciqtz.drv
 '
 'I have tested wave and seq(midi) so far but I am positive
 'that cd and avi would work fine also since ActiveMovie supports
 'them too.
 '
 'What this does for us is allows us to use the simple MCI
 'programming commands and still get mutli-threaded operation.
 'Date: Mon, 10 Jun 2002 18:02:33 -0000
 'From: "Bluepagan" <BluePagan@Yahoo.com>
 
 ' waves.bcx
 ' created by ezide
 GUI "EZIDEPROG"
 
 GLOBAL ghInst AS HANDLE
 GLOBAL hInstance AS HANDLE
 GLOBAL Form1 AS HWND
 GLOBAL Button1 AS HWND
 CONST ID_Button1 = 1
 GLOBAL Button2 AS HWND
 CONST ID_Button2 = 2
 
 GLOBAL MciCommand$
 
 SUB FORMLOAD
 
   ' Start Building Our Form
   Form1 = BCX_FORM("Play Some Waves", 0, 0, 117, 37)
   SetClassLong(Form1, GCL_STYLE, GetClassLong(Form1, GCL_STYLE) | CS_DBLCLKS)
 
   ' Now create all controls
   Button1 = CreateControl(1,"Wave1",ID_Button1, 1409351680, 0, 10, 15, 98, 40)
   Button2 = CreateControl(1,"Wave2",ID_Button2, 1409351680, 0, 121, 15, 97, 40)
 
   DECLARE FUNCTION MCI_Execute LIB "winmm.dll" ALIAS "mciExecute"(A$)
 
   SHOW(Form1) ' Show it!
 END SUB
 
 BEGIN EVENTS
   SELECT CASE CBMSG
   CASE WM_CREATE
 
     EXIT FUNCTION
   CASE WM_COMMAND
     IF CBCTL = ID_Button1 THEN ' Need to rename the wave without spaces
       MciCommand$ = "play " & CHR$(34) & "c:\windows\media\TheMicrosoftSound.wav" & CHR$(34)
       MCI_Execute(MciCommand$)
       EXIT FUNCTION
     END IF
 
     IF CBCTL = ID_Button2 THEN
       MciCommand$ = "play c:\windows\media\Ding.wav"
       MCI_Execute(MciCommand$)
       EXIT FUNCTION
     END IF
   CASE WM_CLOSE
     DestroyWindow(Form1)
     EXIT FUNCTION
   END SELECT
 END EVENTS
 
 FUNCTION CreateControl(CtlType, CtlTxt AS PCHAR, CtlID, CtlStyle, CtlExStyle, w, x, y, z) AS HWND
 
   LOCAL hWndNew AS HANDLE
   ' This LOGFONT struct is used to load indvidual Fonts on all valid Controls
   LOCAL lgf AS LOGFONT
   LOCAL s$
 
   SELECT CASE CtlType
   CASE 1 ' create button control
     lgf.lfHeight = -11
     lgf.lfWidth =  0
     lgf.lfEscapement =  0
     lgf.lfOrientation =  0
     lgf.lfWeight =  400
     lgf.lfItalic =  0
     lgf.lfUnderline =  0
     lgf.lfStrikeOut =  0
     lgf.lfCharSet =  0
     lgf.lfOutPrecision =  0
     lgf.lfClipPrecision =  0
     lgf.lfQuality =  0
     lgf.lfPitchAndFamily =  0
     sprintf(lgf.lfFaceName, "MS Sans Serif")
 
     hWndNew = CreateWindowEx(CtlExStyle, "BUTTON", _
     CtlTxt, CtlStyle, w, x, y, z, Form1, CtlID, ghInst, NULL)
     SetWindowPos(hWndNew, HWND_TOPMOST, w, x, y, z, SWP_NOMOVE|SWP_NOSIZE)
     SendMessage(hWndNew, WM_SETFONT, CreateFontIndirect(&lgf),0)
 
   END SELECT
   FUNCTION = hWndNew
 END FUNCTION