typedef struct
{
unsigned char Clocks;
unsigned char Status; //Note=0x9n, n=Chn:1-16, ProgChg=0xCn, n=Chn
unsigned char Note;
unsigned char Velocity;
} TMidiNote;
unsigned char Phrase[] =
{
0, 0xc0, 0, 0,
0, 0x90, 60, 127,
50, 0x90, 60, 0,
0, 0x90, 60, 127,
50, 0x90, 60, 0,
0, 0x90, 67, 127,
50, 0x90, 67, 0,
0, 0x90, 67, 127,
50, 0x90, 67, 0,
0, 0x90, 69, 127,
50, 0x90, 69, 0,
0, 0x90, 69, 127,
50, 0x90, 69, 0,
0, 0x90, 67, 127,
90, 0x90, 67, 0,
10, 0x90, 65, 127,
50, 0x90, 65, 0,
0, 0x90, 65, 127,
50, 0x90, 65, 0,
0, 0x90, 64, 127,
50, 0x90, 64, 0,
0, 0x90, 64, 127,
50, 0x90, 64, 0,
0, 0x90, 62, 127,
50, 0x90, 62, 0,
0, 0x90, 62, 127,
50, 0x90, 62, 0,
0, 0x90, 60, 127,
100, 0x90, 60, 0,
0, 0x00, 0, 0
};
#define PPQN_TEMPO_FACTOR 10
int test(void)
{
HMIDIOUT handle;
unsigned char * ptr;
unsigned long err;
union
{
DWORD dwData;
UCHAR bData[4];
} u;
if(!(err = midiOutOpen(&handle, (UINT)-1, 0, 0, CALLBACK_NULL)))
{
ptr = &Phrase[0];
do
{
if (*ptr) Sleep(*ptr * PPQN_TEMPO_FACTOR);
ptr++;
u.bData[0] = (UCHAR)*(ptr)++;
u.bData[1] = (UCHAR)*(ptr)++;
u.bData[2] = (UCHAR)*(ptr)++;
u.bData[3] = 0;
if ((err = midiOutShortMsg(handle, u.dwData)))
{
//PrintMidiOutErrorMsg(err);
}
} while (*(ptr + 1));
midiOutClose(handle);
}
else
{
//PrintMidiOutErrorMsg(err);
}
return(0);
}
--------------------next---------------------