when i open a midi port, i can designate a callback function. this function is triggered whenever a midi event is sent to the midi input.
if you really want to understand what i'm doing, here is some of the callback function:
Code:
void CALLBACK midiCallback(HMIDIIN handle, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
{
LPMIDIHDR lpMIDIHeader;
unsigned char *ptr;
TCHAR buffer[80];
unsigned char bytes;
switch (uMsg)
{
// Received some regular MIDI message
case MIM_DATA:
{
// ignore active sensing
if( dwParam1 != 0xF8 ){
unsigned char cc,channel,value;
cc = (dwParam1>>8);
channel = (dwParam1>>0)%16;
value = (dwParam1>>16);
sprintf(&buffer[0], "cc: %d ch: %d v: %d \r\n", cc,
channel,
value);
_cputs(&buffer[0]);
}
break;
}
}
}