User Tools

Site Tools


playing_20multiple_20wav_20files

Playing multiple WAV files

by Richard Russell, February 2013

The method described in the main Help documentation for playing WAV files only allows you to play one file at a time. If you want to play two or more WAV files simultaneously a different approach must be used. The code snippet below demonstrates how to do it:

        wavfile1$ = "C:\windows\media\Windows XP Shutdown.wav"
        wavfile2$ = "C:\windows\media\Windows XP Startup.wav"
 
        SYS "mciSendString", "close wav1", 0, 0, 0
        SYS "mciSendString", "close wav2", 0, 0, 0
        SYS "mciSendString", "open """ + wavfile1$ + """ alias wav1", 0, 0, 0
        SYS "mciSendString", "open """ + wavfile2$ + """ alias wav2", 0, 0 ,0
        SYS "mciSendString", "play wav1", 0, 0, 0
        SYS "mciSendString", "play wav2", 0 ,0, 0

Note that the close commands are not required if the code is executed only once.

If you want to test whether a file has finished playing you can do so as follows:

        reply1$ = STRING$(16, CHR$(0))
        reply2$ = STRING$(16, CHR$(0))
        SYS "mciSendString", "status wav1 length", reply1$, LEN(reply1$), 0
        SYS "mciSendString", "status wav1 position", reply2$, LEN(reply2$), 0
        IF reply1$ = reply2$ THEN PRINT "Finished playing"
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
playing_20multiple_20wav_20files.txt · Last modified: 2018/04/15 13:05 by richardrussell