PLAYWAV plays the sound contained in a .wav soundfile.
Syntax 1:PLAYWAV(SoundFile AS STRING [, SoundFlags AS INTEGER]) Parameters:
|
Syntax 2:PLAYWAV("", Resource_ID AS INTEGER [, SoundFlags AS INTEGER]) Parameters:
|
Save the example code below as playwav.bas, save the following batch file into the same directory as playwav.bas and run the batch file to compile and run the example.
Build.bat Compilation Batch file:
CALL povars64.bat bc playwav
playwav.bas
$IPRINT_OFF $RESOURCE "$PELLES$\bin\porc.exe" $COMPILER "$PELLES$\Bin\pocc -W1 -Gd -Go -Ze -Zx -Tx64-coff $FILE$.c" $LINKER "$PELLES$\Bin\polink _ -release _ -machine:X64 _ -subsystem:console _ -OUT:$FILE$.exe _ $FILE$.obj _ $FILE$__.res" BCX_RESOURCE 1234 RCDATA "C:\Windows\Media\Windows Logon.wav" PLAYWAV("", 1234)
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 cannot play two .mid files at the same time. This demo uses the town.mid file distributed with Windows and Scott Frick's BCX.wav file from his MultiSound demo.
Click here to download a .zip containg BCX.wav.
Extract the BCX.wav file and place it in the same directory as the PlayMT.exe compiled from the BCX code below. Run the demo, click on the Start button and then click on the Overlay button and you will hear Scott's .wav voice superimposed over the town.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$ MACRO ID_Button1 = 101 MACRO ID_Button2 = 102 SUB FORMLOAD Form1 = BCX_FORM("Play Multi-Thread", 0, 0, 140, 30) Button1 = BCX_BUTTON("Start", Form1, ID_Button1, 7, 5, 60, 16) Button2 = BCX_BUTTON("Overlay", Form1, ID_Button2, 71, 5, 60, 16) FileName1$ = "C:\Windows\Media\town.mid" FileName2$ = "BCX.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) CENTER(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