
Routines that play MIDI files...
Quote:
> I was wondering where I might be able to find some source code written in
> either C or Basic that could open and play midi files (*.mid or *.rmi). So
> far my search has turned out nothing, except a bunch of info on how to
> program the FM registers and routines that play music files not in the MID
> format.
You didn't tell which operating system you are using.
Here is a simple C solution for Windows with MCI (mmsystem.dll)
(see MCI help files and manuals or book
Microsoft Multimedia Programmer's Reference).
------------------------------------
#include <mmsystem.h>
#include <string.h>
char retMCI[128];
int errorMCI = 0;
void MCI(const char* cmd)
{
errorMCI = mciSendString(cmd, retMCI, sizeof(retMCI)-1, NULL);
Quote:
}
void PlayMidi(const char* filename)
{
char cmd[128];
strcpy(cmd, "open ");
strcat(cmd, filename);
strcat(cmd, " alias simplemidi wait");
MCI(cmd);
MCI("play simplemidi");
Quote:
}
void StopMidi()
{
MCI("stop simplemidi");
MCI("close simplemidi");
Quote:
}
----------------------------------------------------