Sketch for MIDI in to control Tone Function

This is the UART irq handler for my dsp-G1 synthesizer.
Its written for the ARM cortex but show what you need to deal with.

void UART0_IRQHandler(void) {
      uint8_t MIDIRX;
	  while (!(LPC_USART0->STAT & UART_STATUS_TXRDY));
	  MIDIRX = LPC_USART0->RXDATA;

	  /*
	  Handling "Running status"
	  1.Buffer is cleared (ie, set to 0) at power up.
	  2.Buffer stores the status when a Voice Category Status (ie, 0x80 to 0xEF) is received.
	  3.Buffer is cleared when a System Common Category Status (ie, 0xF0 to 0xF7) is received.
	  4.Nothing is done to the buffer when a RealTime Category message is received.
	  5.Any data bytes are ignored when the buffer is 0.
	  */

	  if ((MIDIRX>0xBF)&&(MIDIRX<0xF8)) {
		  MIDIRUNNINGSTATUS=0;
		  MIDISTATE=0;
		  return;
	  }

	  if (MIDIRX>0xF7) return;

	  if (MIDIRX & 0x80) {
		  MIDIRUNNINGSTATUS=MIDIRX;
		  MIDISTATE=1;
		  return;
	  }

	  if (MIDIRX < 0x80) {
	  	  if (!MIDIRUNNINGSTATUS) return;
	  	  if (MIDISTATE==1) {
	  		  MIDINOTE=MIDIRX;
	  		  MIDISTATE++;
	  		  return;
	  	  }
	  	  if (MIDISTATE==2) {
	  		  MIDIVEL=MIDIRX;
	  		  MIDISTATE=1;
	  		  if ((MIDIRUNNINGSTATUS==0x80)||(MIDIRUNNINGSTATUS==0x90)) handleMIDINOTE(MIDIRUNNINGSTATUS,MIDINOTE,MIDIVEL);
	  		  if (MIDIRUNNINGSTATUS==0xB0) handleMIDICC(MIDINOTE,MIDIVEL);

	  		  return;
	  	  }
	  	  }

	  return;
}

This code handles just the note on/off and MIDI#CC messages but its the bare minimum you need to handle.