# Playing a sequence of WAV files



## Russell Morton (Apr 2, 1999)

I am using VB6 and the multimedia control. I am trying to play a sequence of wav files with as small a gap as possible between them. I am trying to use two multimedia controls, and que one up while the other is playing.

I cant seem to get the control order correct, also I get different results when I send the "Play" command and the "Sound" command.

I cant seem to get an end of file event with "Sound", while "Play" only works on the first of the two controls.

Help.

Is there a way to "join" the wav files prior to playing them ?


----------



## Mosaic1 (Aug 17, 2001)

There is. But it will depend on how large the files are and what software you have. The basic is Windows Sound Recorder. Not much memory there. But you can use the insert file method. Open Sound Recorder And Choose Edit>Insert File on the toolbar. A dialog will pop up and you can browse to the file you want to use. Then move the slider to the right all the way to the end. Choose Edit>Insert File again. and on and on until you are out of memory or have what you want. Or you may need to get a better utility .


----------



## Russell Morton (Apr 2, 1999)

Each individual file is one minute, 1.2 MByte or so. Also I would need to do the join from within the VB program. I could end up with a very large file since the maximum recording time is 12 hours !

Thats why I came up with the idea of using two MCI controls. I just can get the open close sequence correct with the Done callback event.


----------



## Mosaic1 (Aug 17, 2001)

That's really large. How long is the pause between Waves now?
would it be OK to have Media Player showing?

You can create an M3U, a playlist from within VB.

Open App.Path & "Songs.m3u" etc

and write to it.
An M3U is just a list of files. No Quotations around the path. entire path and filename. Are you using a resource file to hold the songs? 

Then if you wanted to open that in Media Player, you could use Shell.


----------



## bassetman (Jun 7, 2001)

This isn't my area, but Analogx has a bunch of files for dealing with audio stuff here:
http://www.analogx.com/contents/download/audio.htm

Hope something there helps.


----------



## cassamine (Nov 22, 2002)

Well if you are working with WAV files only then you can use the following API

*Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long*

Example of use.

*sndPlaySound("c:\FullPathOfFile.wav",3)*

by this method you can play the file asynchronously with your application.

Now the problem arises how to get the length of wav file, to know when start playing another file.

To learn doing that goto this short tutorial page.

* http://www.vb2themax.com/Item.asp?PageID=TipBank&ID=162 *

cassamine


----------



## cassamine (Nov 22, 2002)

i forgot to ask, r u at easy with API. if not ill help, mail me.

cassamine


----------



## Mosaic1 (Aug 17, 2001)

I had posted a longer response but have deleted it. I worked out a way to play an array of sounds and use the Sleep API in between each one. It worked great for very short Windows event sounds. However, when I added a long Wav, and then another, the program didn't perform and eventually froze.


----------



## Russell Morton (Apr 2, 1999)

Sure API's are not a problem, but the key is getting the callback when the Play is done. This is relatively easy with the MCI control by enabling notify. What seems to be impossible is to have two MCI controls both set to waveaudio, even though I close one before opening the other. 

My idea was to set up the non playing control with the next file wheh the playing control was half way through, then on the Done event, close the running MCI, and open the next one then do play. What I get is the error that the control does not support this action ( Play ). 

I have gone back to a single MCI control, and it seems to be working reasonably fast.

Now does anyone know about a VU meter control that actually works ???


Thanks for all your help.


----------

