Actually, the provided example does not compile. I had to add:
void handleNoteOn(byte channel, byte pitch, byte velocity);
void handleNoteOff(byte channel, byte pitch, byte velocity);
before the setup() otherwise it cannot find the functions (declared below).
About the MIDI the original code works:
$ aseqdump -l
Port Client name Port name
0:0 System Timer
0:1 System Announce
14:0 Midi Through Midi Through Port-0
32:0 BPI-Leaf-S3 BPI-Leaf-S3 MIDI 1
I wonder what is my mistake in my code.