HELP: Can't play MIDI and WAV at same time 
Author Message
 HELP: Can't play MIDI and WAV at same time

HELP!!!!

I can't play a midi file and wave file at the same time.  Here is my code:

Private Declare Function mciSendString Lib "winmm.dll" Alias
"mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As
String, ByVal uReturnLength As Integer, ByVal hWndCallback As Integer) As
Long
Private Declare Function mciGetErrorString Lib "winmm.dll" Alias
"mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String,
ByVal uLength As Long) As Long

    SSResult = mciSendString("close mymid", ReturnString, LenStr, 0)

    SSResult = mciSendString("open c:\windows\media\canyon.mid type
sequencer alias mymid", ReturnString, LenStr, 0)

    SSResult = mciSendString("play mymid from 1", ReturnString, LenStr, 0)

    SSResult = mciSendString("close mywav", ReturnString, LenStr, 0)

    SSResult = mciSendString("open c:\windows\media\chimes.wav type
waveaudio alias mywav wait", ReturnString, LenStr, 0)

    SSResult = mciSendString("play mywav from 1", ReturnString, LenStr, 0)

    SSResult = mciSendString("close mywav", ReturnString, LenStr, 0)

    SSResult = mciSendString("close mymid", ReturnString, LenStr, 0)

When I try it, it plays the midi file, then when it gets to "play mywav from
1" it returns the error code for "MMSYSTEM320 All wave devices that can play
files in this format are in use. Try again when a wave device is free."
(which I converted using the GetStringError function).

It also doesn't work for playing midi files this way and using sndPlaySound
function!!!!!!!  What would be the solution!?!?  I need help ASAP (hopefully
today).  Thanks in advance.

Natman



Sat, 02 Jun 2001 03:00:00 GMT  
 HELP: Can't play MIDI and WAV at same time

Quote:
>I can't play a midi file and wave file at the same time.  Here is my code:

Not all soundcards/drivers can play midi and wave at the same time, that
seems to be the problem in your case.

Solution:

1. check for new drivers for your soundcard, if it don't work goto 2
2. buy a new soundcard



Sat, 02 Jun 2001 03:00:00 GMT  
 HELP: Can't play MIDI and WAV at same time
But other programs can do it easily, Only I can't do it with VB5....

    Natman

Quote:

>>I can't play a midi file and wave file at the same time.  Here is my code:

>Not all soundcards/drivers can play midi and wave at the same time, that
>seems to be the problem in your case.

>Solution:

>1. check for new drivers for your soundcard, if it don't work goto 2
>2. buy a new soundcard



Sat, 02 Jun 2001 03:00:00 GMT  
 HELP: Can't play MIDI and WAV at same time
The MCI can only operate one device at a time. You could probably play the
sound file with something else and use the MCI to play the MIDI file. Use
the low level api or possibly sndPlaySound

Thomas Martin

Quote:

>But other programs can do it easily, Only I can't do it with VB5....

>    Natman


>>>I can't play a midi file and wave file at the same time.  Here is my
code:

>>Not all soundcards/drivers can play midi and wave at the same time, that
>>seems to be the problem in your case.

>>Solution:

>>1. check for new drivers for your soundcard, if it don't work goto 2
>>2. buy a new soundcard



Sat, 02 Jun 2001 03:00:00 GMT  
 HELP: Can't play MIDI and WAV at same time
Hi,
try the MS Multimedia control,  maybe a 2nd instance for the WAV file
with the 1st playing the MIDI file.
Chris

In reply to Natman scribbling down the following on the subject of
HELP: Can't play MIDI and WAV at same time

Quote:
>HELP!!!!

>I can't play a midi file and wave file at the same time.  Here is my code:

>Private Declare Function mciSendString Lib "winmm.dll" Alias
>"mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As
>String, ByVal uReturnLength As Integer, ByVal hWndCallback As Integer) As
>Long
>Private Declare Function mciGetErrorString Lib "winmm.dll" Alias
>"mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String,
>ByVal uLength As Long) As Long

>    SSResult = mciSendString("close mymid", ReturnString, LenStr, 0)

>    SSResult = mciSendString("open c:\windows\media\canyon.mid type
>sequencer alias mymid", ReturnString, LenStr, 0)

>    SSResult = mciSendString("play mymid from 1", ReturnString, LenStr, 0)

>    SSResult = mciSendString("close mywav", ReturnString, LenStr, 0)

>    SSResult = mciSendString("open c:\windows\media\chimes.wav type
>waveaudio alias mywav wait", ReturnString, LenStr, 0)

>    SSResult = mciSendString("play mywav from 1", ReturnString, LenStr, 0)

>    SSResult = mciSendString("close mywav", ReturnString, LenStr, 0)

>    SSResult = mciSendString("close mymid", ReturnString, LenStr, 0)

>When I try it, it plays the midi file, then when it gets to "play mywav from
>1" it returns the error code for "MMSYSTEM320 All wave devices that can play
>files in this format are in use. Try again when a wave device is free."
>(which I converted using the GetStringError function).

>It also doesn't work for playing midi files this way and using sndPlaySound
>function!!!!!!!  What would be the solution!?!?  I need help ASAP (hopefully
>today).  Thanks in advance.

>Natman



Mon, 04 Jun 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. MIDI playing and multiple MIDI's.

2. Play 2+ WAV's at one time?

3. help playing wav's (here's the code)

4. How to play MIDI and WAV from VB ????

5. Playing WAV files and MIDI files

6. How to play MIDI and WAV from VB ????

7. Midi and Wav auto-play

8. Playing Large Wav and Midi without DoEvents

9. How To Play MIDI/WAV Sounds

10. Playing WAV and MIDI files in VB 4.0

11. Playing Large Wav and Midi without DoEvents

12. Play WAV and MIDI

 

 
Powered by phpBB® Forum Software