works: MIDI-IN: code + schematics

Hey guys,

I've managed to get a small instrument working using this code, but I've also encountered the same problem as Captain Credible (reply #41 on page 3), in that through some MIDI interfaces I can't play more than one note.

If I connect the instrument directly to my MIDI keyboard, I can play polyphonically, but if I play through my keyboard into MIDI-OX and out through a separate MIDI interface (a MOTU MIDI Express XT) I can only play monophonically.

Does anyone have an idea as to why this might be happening?

At first I thought it was because of the note-off differences, between actually specifying a note-off message (128) and a note-on with velocity = 0, but as far as I can tell they both do the note-on, vel=0 thing.

I've been racking my brain all day over this, but I'm truly stumped. Any help would be very gratefully received.

MIDI portion of code below:

  if (Serial.available() > 0) {
    blink();
    incomingByte = Serial.read();
    if (incomingByte == 144) {
      action = 1;
    }else if (incomingByte == 128) {
      action = 0;
    }else if ((action == 0) && (note == 0)) {
      note = incomingByte;
      playNote(note, 0);
      note = 0;
      velocity = 0;
      action = 2;
    }else if ((action == 1) && (note == 0)) {
      note = incomingByte;
    }else if ((action == 1) && (note != 0)) {
      velocity = incomingByte;
      playNote(note, velocity);
      note = 0;
      velocity = 0;
      action = 0;
    }else{
    }
  }