Arduino Midi to Gate

if (Serial.available()){
     commandByte = Serial.read();//read first byte
     noteByte = Serial.read();//read next byte
     velocityByte = Serial.read();//read final byte

So read three bytes from the serial port if one or more are available? Not a very good strategy. The while condition at the end only kicks in at the end.

Avoid the 'do' - 'while' structure, it is not needed and only leads a beginner into confusion.

Also reading three bytes at a time assumes you are not going to get any one or two byte MIDI messages, can you guarantee that?