I was playing with the attached sketch to work out exactly what my MIDI keyboard was sending.
Example output:
1191616: Control change channel = 1, General Purpose Controller 1 (MSB): 0x40
5532: Note off channel = 1, note = D (5) , velocity = 99
2740: Note on channel = 1, note = E (0) , velocity = 127
4528: Note on channel = 1, note = D (4) , velocity = 63
46184: After-touch pressure channel = 1, value = 31
15328: After-touch pressure channel = 1, value = 127
29776: Note off channel = 1, note = D (5) , velocity = 64
5708: After-touch pressure channel = 1, value = 49
10664: After-touch pressure channel = 1, value = 18
13256: After-touch pressure channel = 1, value = 9
Changing instruments:
1115248: Control change channel = 1, Bank Select (MSB): 0x3F
1964: Control change channel = 1, Bank Select (LSB): 0x4
2064: Program change channel = 1, program = 42
3832: System: Exclusive (in hex), vendor ID = 66
30 7A 40 0 0 44 61 6E 63 65 20 4C 0 65 61 64 20 20 20 20 20 20 20 A 3C 0 30 14 50 27 0 14 5F
48 2 14 2 28 19 55 0 31 40 2 20 0 40 0 7F 7F 4E 23 0 40
Another tune from the device:
486436: Note off channel = 1, note = C (4) , velocity = 64
2036: Note on channel = 1, note = G (4) , velocity = 105
2120: Note off channel = 1, note = D (4) , velocity = 114
4532: Note on channel = 1, note = A#(3) , velocity = 105
75416: Note off channel = 1, note = A (3) , velocity = 64
6988: Note off channel = 1, note = F (4) , velocity = 64
503724: Note on channel = 1, note = A (4) , velocity = 102
2120: Note on channel = 1, note = E (4) , velocity = 117
2212: Note on channel = 1, note = C (4) , velocity = 99
4444: Note on channel = 1, note = B (3) , velocity = 99
10344: Note off channel = 1, note = B (3) , velocity = 0
76212: Note off channel = 1, note = D (4) , velocity = 64
2036: Note off channel = 1, note = A#(3) , velocity = 64
41684: Note off channel = 1, note = G (4) , velocity = 64
872724: Note off channel = 1, note = C (4) , velocity = 64
147928: Note off channel = 1, note = A (4) , velocity = 64
Pitch wheel changes:
136802728: Note on channel = 1, note = D#(4) , velocity = 111
24208: After-touch pressure channel = 1, value = 0
106028: Pitch wheel change channel = 1, value = 9560
13056: Pitch wheel change channel = 1, value = 16383
133788: Note off channel = 1, note = D#(4) , velocity = 64
19176: Pitch wheel change channel = 1, value = 16045
11352: Pitch wheel change channel = 1, value = 12053
11644: Pitch wheel change channel = 1, value = 8192
72888: After-touch pressure channel = 1, value = 0
94608: Note on channel = 1, note = G#(4) , velocity = 105
217200: Note off channel = 1, note = G#(4) , velocity = 64
8080: Note on channel = 1, note = A#(4) , velocity = 105
38220: After-touch pressure channel = 1, value = 6
11336: After-touch pressure channel = 1, value = 127
35416: After-touch pressure channel = 1, value = 42
11356: After-touch pressure channel = 1, value = 0
34140: Note off channel = 1, note = A#(4) , velocity = 64
264208: Note on channel = 1, note = C#(5) , velocity = 102
244728: After-touch pressure channel = 1, value = 5
13324: After-touch pressure channel = 1, value = 21
11352: After-touch pressure channel = 1, value = 42
15388: After-touch pressure channel = 1, value = 0
11360: After-touch pressure channel = 1, value = 80
11624: After-touch pressure channel = 1, value = 101
11080: After-touch pressure channel = 1, value = 127
404408: After-touch pressure channel = 1, value = 42
11060: After-touch pressure channel = 1, value = 3
15400: After-touch pressure channel = 1, value = 0
144136: Note off channel = 1, note = C#(5) , velocity = 64
4180: Note on channel = 1, note = A#(4) , velocity = 99
52116: After-touch pressure channel = 1, value = 15
9592: After-touch pressure channel = 1, value = 21
13120: After-touch pressure channel = 1, value = 2
11332: After-touch pressure channel = 1, value = 0
64000: Note off channel = 1, note = A#(4) , velocity = 64
204316: Note on channel = 1, note = G#(4) , velocity = 96
As written, you connect your MIDI device up to pin D2 (for NewSoftSerial). It uses hardware serial at 115200 to send the above message to your monitor window. I had to fiddle slightly with NewSoftSerial to make it compatible with version 1.0 of the IDE, but if you grab the latest version that probably won't be necessary.
You need to compiler under version 1.0+ of the IDE to get the "F" macro which is used to save SRAM by keeping literal strings in program memory.
The number on the left shows the number of microseconds between each message, so you can see which ones come closely together.
Note values are interpreted, eg. C(4) is Middle C.
As far as possible I interpreted incoming messages as per the tables on this page:
You need the "streaming" library for the sketch to compile:
http://arduiniana.org/libraries/streaming/
MIDI_decoder.ino (13.2 KB)