Useful Links
Example file

A 2-track MIDI file.
#view the content of a midi file
xxd example.midi
00000000: 4d54 6864 0000 0006 0001 0002 0078 4d54 MThd.........xMT
00000010: 726b 0000 0019 00ff 5804 0201 3008 00ff rk......X...0...
00000020: 5902 0300 00ff 5103 0927 c000 ff2f 004d Y.....Q..'.../.M
00000030: 5472 6b00 0000 4100 ff21 0100 00c0 4778 Trk...A..!....Gx
00000040: 9040 6478 4000 0040 6478 4000 0040 6478 .@dx@..@dx@..@dx
00000050: 4000 0045 6482 6845 0000 4764 7847 0000 @..Ed.hE..GdxG..
00000060: 4964 8170 4900 004c 6481 704c 0000 4c64 Id.pI..Ld.pL..Ld
00000070: 8360 4c00 00ff 2f00 .`L.../.
Header
4d54 6864 0000 0006 0001 0002 0078
4d54 6864 Mthd (4 bytes)
0000 0006 length of header chunk (4 bytes)
0001 format (2 bytes) (0/1/2 - single track/multi track/multi song)
0002 number of tracks (2 bytes)
0078 division (2 bytes)
Track 1
4d54 726b 0000 0019 00ff 5804 0201 3008
00ff 5902 0300 00ff 5103 0927 c000 ff2f 00
4d54 726b Mtrk (4 bytes)
0000 0019 number of bytes in the track following this num (4 bytes)
00ff 00: at time 0 ff: meta event header
5804 58: time signature 04: length of meta event
0201 02: "2" of "2"/2 01: denominator is 2^1, which is 2. this line means 2/2
3008 30: 48 MIDI clocks per metronome click. 08: 8 notated 32nd-notes in a MIDI quarter-note(24 MIDI clock)
00ff 00: at time 0 ff: meta event header
5902 59: Key signature 02: length of meta event
0300 03: 3 sharps(A) 00: major key
00ff 00: at time 0 ff: meta event header
5103 51: Tempo setting 03: length of meta event
0927c0 microseconds per quarter note. 0x0927c0 = 600000. 100 BPM
00ff 00: at time 0 ff: meta event header
2f00 2f: end of track 00: length of meta event
Track 2
4d54 726b 0000 0041 00ff 2101 0000 c047
7890 4064 7840 0000 4064 7840 0000 4064
7840 0000 4564 8268 4500 0047 6478 4700
0049 6481 7049 0000 4c64 8170 4c00 004c
6483 604c 0000 ff2f 00
4d54 726b Mtrk
0000 0041 number of bytes in the track following this num (65)
00ff 00: at time 0 ff: meta event header
210100 prefix port: 0
00 00: at time 0
c047 c0: Select the specified program on channel 0 47: clarinet
78 78: 120 ticks
90 90: notes on, at channel 0
406478 40: pitch E4 64: velocity 100 78: 120 ticks
400000 40: pitch E4 00: velocity 0 00: 0 ticks (note-off) [in running status, 90 note-on status bytes are omitted]
406478 40: pitch E4 64: velocity 100 78: 120 ticks
400000 40: pitch E4 00: velocity 0 00: 0 ticks (note-off)
406478 40: pitch E4 64: velocity 100 78: 120 ticks
400000 40: pitch E4 00: velocity 0 00: 0 ticks (note-off)
4564 8268 45: pitch A4 64: velocity 100 8268: 360 ticks
450000 40: pitch A4 00: velocity 0 00: 0 ticks (note-off)
476478 47: pitch B4 64: velocity 100 78: 120 ticks
470000 47: pitch B4 00: velocity 0 00: 0 ticks (note-off)
4964 8170 49: pitch #C5 64: velocity 100 8170: 240ticks
490000 49: pitch #C5 00: velocity 0 00: 0 ticks (note-off)
4c64 8170 4c: pitch E5 64: velocity 100 8170: 240ticks
4c0000 4c: pitch E5 00: velocity 0 00: 0 ticks (note-off)
4c64 8360 4c: pitch E5 64: velocity 100 8360: 360ticks
4c0000 4c: pitch E5 00: velocity 0 09: 0 ticks (note-off)
ff2f00 ff: meta event header 2f: end of track 00: length of meta event