Code Snippets
Code Samples

The Blog
Our Projects

::Add RageStorm to Favorites!::

The Blog | Our Projects | Guest Book | About | Contact

Tutorial - MCI
Uploaded at:29-May-03
The MCI which stands for Media Control Interface is very easy to use.
In this tutorial I'll show you how to load a .MID and play it.
Most of the MCI calls are done through the mciSendCommand(...) function,
whenever we use this function we need an ID for the device player,
so if we want to stop the playing for instance we need to pass the
device ID that plays the MIDI and tell it to stop...So we'll save this ID.
Let's start then:
We tell the MCI to load a MIDI off a file and to start playing(once).
MCI_OPEN_PARMS mciOpenParms;
// "sequencer" - means we want to play a MIDI.
mciOpenParms.lpstrDeviceType = "sequencer";
// The MIDI file name.
mciOpenParms.lpstrElementName = strFileName;
// We open the MIDI for playing.
MIDI_Device = mciOpenParms.wDeviceID;
// Getting the Device ID which will play the MIDI.

MCI_PLAY_PARMS mciPlayParms;
// This struct is for the playing parameters we want. 
// We pass the handle of the window because when the MIDI
// will be finished playing, it will notify us (then we may
// play it again[looped]).
mciPlayParms.dwCallback = (DWORD)hWnd;
mciSendCommand(MIDI_Device, MCI_PLAY, MCI_NOTIFY, (DWORD)&mciPlayParms);

OK that was it for loading and playing, MCI does life easy, HUH? :)
Now let's see how to close the device player(this will free the MIDI too):
// Closing the MIDI.
if (MIDI_Device) mciSendCommand(MIDI_Device, MCI_CLOSE, 0, NULL);
MIDI_Device = NULL;

Well you gotta see the source code, it has a REAL nice GUI,
and you may learn how to use dialog boxes....Check it out!

Source Code:
Visual C++ 6 - MIDI.zip

User Contributed Comments(1)
 [1] Peter | 2007-08-24 16:30:32

Finally! Great!
Comments that will hurt anyone in any way will be deleted.
Don't ask for features, advertise or curse.
If you want to leave a message to the author use the contacts,
if you have any question in relation to your comments please use the forum.
Comments which violate any of these requests will be deleted without further
notice. Use the comment system decently.

Post your comment:
::Top 5 Tutorials::
Embedded Python[118254]
2D Rotated Rectangles Collision Detection[89607]
Keyboard Hook[77985]
HTTP Proxy[41741]

::Top 5 Samples::
2D ColDet Rotated Rectangles[11590]
PS2 Mouse Driver[6989]
Wave Format Player[5815]
Reading FAT12[5642]

All rights reserved to RageStorm © 2009