Midi and Wav auto-play 
Author Message
 Midi and Wav auto-play

Could any help me out by telling me how to auto play a sound when there is a
certain condition(eg. Play a sound if a person gets an answer right) Or how
can u play a midi when the program starts or when it ends.. And how can u
play a sound during the program!  THANKS A LOT!!!!



Sun, 08 Oct 2000 03:00:00 GMT  
 Midi and Wav auto-play

Quote:

> Could any help me out by telling me how to auto play a sound when there is a
> certain condition(eg. Play a sound if a person gets an answer right) Or how
> can u play a midi when the program starts or when it ends.. And how can u
> play a sound during the program!  THANKS A LOT!!!!

  Here is how to play a midi file:
First you need to create a bas module. You can name it whatever you want, but
you will need this line in it:

Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal
lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength
As Long, ByVal hwndCallBack As Long) As Long

Then let's go on to the main program. First you have to load the file, and that
is done like this:
  Dim ret As Integer ' Put this line in load or something like that. ret must be
defined as an Integer.

  ret = mciSendString("open d:\starwar2.MID type sequencer alias STARWARS", 0&,
0, 0)
In this example I played a Starwars midi file. But you can change it to play
whatever you want.

Then the file is ready to be played. And here is how to do just that:
  ret = mciSendString("play STARWARS", 0&, 0, 0)

To stop the music, you have to include something like this in your program:
 ret = mciSendString("close STARWARS", 0&, 0, 0)

Then it is the wav files. It is done almost the same way.
Let's get down to it.

You have to load the file first. Like the midi files. Here is how it is done:
  Dim ret As Integer
  ret = mciSendString("open d:\barking.wav type waveaudio alias wavefile", 0&,
0, 0)

And here is how to play it.
  ret = mciSendString("play wavefile", 0&, 0, 0)

If you want to close the file, type:
 ret = mciSendString("close wavefile", 0&, 0, 0)

That should do it. Hope you will get it to work properly. I have tested the code
before I posted it to you.

Greetings from Ronny Soltveit, Norway.



Tue, 10 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to Auto play a MIDI file when document opens

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

3. Playing WAV files and MIDI files

4. HELP: Can't play MIDI and WAV at same time

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

6. Playing Large Wav and Midi without DoEvents

7. How To Play MIDI/WAV Sounds

8. Playing WAV and MIDI files in VB 4.0

9. Playing Large Wav and Midi without DoEvents

10. Play WAV and MIDI

11. MIDI playing and multiple MIDI's.

12. WAV or MIDI player in QBASIC?????

 

 
Powered by phpBB® Forum Software