Assignment 7
MIDI File Parsing

Here is an example MIDI file displayed as ASCII Hex values:
 4d 54 68 64 00 00 00 06 00 00 00 01 00 80 4d 54 72 6b 00 00 00 8c 00 ff 58 
 04 04 02 30 08 00 ff 59 02 00 00 00 90 3c 28 81 00 90 3c 00 00 90 3c 1e 81 
 00 90 3c 00 00 90 43 2d 81 00 90 43 00 00 90 43 32 81 00 90 43 00 00 90 45 
 2d 81 00 90 45 00 00 90 45 32 81 00 90 45 00 00 90 43 23 82 00 90 43 00 00 
 90 41 32 81 00 90 41 00 00 90 41 2d 81 00 90 41 00 00 90 40 32 40 90 40 00 
 40 90 40 28 40 90 40 00 40 90 3e 2d 40 90 3e 00 40 90 3e 32 40 90 3e 00 40 
 90 3c 1e 82 00 90 3c 00 00 ff 2f 00 

Your assignment is to parse one of the MIDI files in this directory, in a style similar to the following for the above example MIDI file. (You can listen to the actual MIDI file by downoading the real MIDI file from this directory).

4d 54 68 64 		== "MThd" which marks the start of a MIDI file
00 00 00 06 		== The size in bytes of the rest of the Header chunk.
			   This value is always 6 for Standard MIDI Files.
00 00			== MIDI format, which is a Type-0 MIDI file
			   which means that there is only one track in the file.
00 01 			== The number of tracks to follow in the file
00 80 			== The number of ticks per quarter note (128)
			End of MIDI Header

4d 54 72 6b 		== "MTrk" which marks the start of a MIDI track
00 00 00 8c 		== The size in bytes of the rest of the track.
			   This value is incorrect in about 50% of all
			   MIDI files, and should be ignored.
00 			== Delta time of the first MIDI message (0 ticks)
   ff 58 04 04 02 30 08 == Meta Message #58 = Time Signature
			     Message contains 4 bytes: 04 02 30 08
			     04 = four beats per measure
			     02 = 2^2 = 4 --> quarter note is the beat
			     30 = 48 decimal --> clock ticks par quarter note 
                                  (tempo 60 beats per minute)
                             08 = 8 32nd notes per quarter note (beat)
00 			== Delta time for next message (0 = no wait)
   ff 59 02 00 00       == Meta Message #59 = Key signature
			     Message contains 2 bytes: 00 00
			     00 = no sharps or flats
			     00 = major mode (01 = minor)
00 			== Delta time for next message (0 = no wait)
   90 3c 28 		== Note-On Message (middle C4)
81 00 			== Delta time	(128 ticks = quarter note)
   90 3c 00 		== Note-Off Message (C4)
00 			== Delta time	(0 ticks)
   90 3c 1e 		== Note-On Message (middle C4)
81 00 			== Delta time	(128 ticks = quarter note)
   90 3c 00 		== Note-Off Message (C4)
00 			== Delta time   (0 ticks)
   90 43 2d 		== Note-On Message (G4)
81 00 			== Delta time	(128 ticks = quarter note)
   90 43 00 		== Note-Off Message (G4)
00 			== Delta time   (0 ticks)
   90 43 32 		== Note-On Message (G4)
81 00 			== Delta time	(128 ticks = quarter note)
   90 43 00 		== Note-Off Message (G4)
00 			== Delta time   (0 ticks)
   90 45 2d 		== Note-On Message (A4)
81 00 			== Delta time	(128 ticks = quarter note)
   90 45 00 		== Note-Off Message (A4)
00 			== Delta time   (0 ticks)
   90 45 32 		== Note-On Message (A4)
81 00 			== Delta time	(128 ticks = quarter note)
   90 45 00 		== Note-Off Message (A4)
00 			== Delta time   (0 ticks)
   90 43 23 		== Note-On Message (G4)
82 00 			== Delta time	(256 ticks = half note)
   90 43 00 		== Note-Off Message (G4)
00 			== Delta time   (0 ticks)
   90 41 32 		== Note-On Message (F4)
81 00 			== Delta time	(128 ticks = quarter note)
   90 41 00 		== Note-Off Message (F4)
00 			== Delta time   (0 ticks)
   90 41 2d 		== Note-On Message (F4)
81 00 			== Delta time	(128 ticks = quarter note)
   90 41 00 		== Note-Off Message (F4)
00 			== Delta time   (0 ticks)
   90 40 32 		== Note-On Message (E4)
40 			== Delta time	(64 ticks = eighth note)
   90 40 00 		== Note-Off Message (E4)
40 			== Delta time	(64 ticks = eighth note)
   90 40 28 		== Note-On Message (E4)
40 			== Delta time	(64 ticks = eighth note)
   90 40 00 		== Note-Off Message (E4)
40 			== Delta time	(64 ticks = eighth note)
   90 3e 2d 		== Note-On Message (D4)
40 			== Delta time	(64 ticks = eighth note)
   90 3e 00 		== Note-Off Message (D4)
40 			== Delta time	(64 ticks = eighth note)
   90 3e 32 		== Note-On Message (D4)
40 			== Delta time	(64 ticks = eighth note)
   90 3e 00 		== Note-Off Message (D4)
40 			== Delta time	(64 ticks = eighth note)
   90 3c 1e 		== Note-On Message (C4)
82 00 			== Delta time	(256 ticks = half note)
   90 3c 00 		== Note-Off Message (C4)
00 			== Delta time
   ff 2f 00 		== Meta Message #2f -- End of Track Marker
			   Number of bytes in Message: 0
			   This Meta Message is REQUIRED at the end of
			   a track (since the byte size in the track
			   header is often wrong).

You should do the first 100 parsed elements in the MIDI file that you choose. Select one MIDI file from the following range assigned to each student:

11b-ma1.asc		-- Adnan
acso3op2.asc
alkqufa.asc
anna-04.asc
arioso.asc
ari_ytng.asc
artstlif.asc
at01op10.asc
babwv667.asc
bandera.asc
beet271.asc		-- Isak
be-ps-09.asc
bjs959.asc
bjspreii.asc
bwv864.asc
cancion.asc
canzona.asc
carandan.asc
carentr3.asc
cb2.asc
cdpol153.asc		-- Kimberley
cheerful.asc
ch-ps-03.asc
conta01.asc
contra03.asc
coqdor1.asc
corel-3.asc
csminpr.asc
drm_sanc.asc
dvop22-3.asc
fieno6.asc		-- Luke
fieno8.asc
flczma.asc
fountain.asc
fratfuga.asc
god104.asc
god2511.asc
gp_fa_gc.asc
gp_syl-3.asc
gymnop02.asc
hans3c.asc		-- Maureen
hestcust.asc
hfantinc.asc
intermas.asc
italian.asc
jmngfune.asc
jwasa.asc
k330-2.asc
knnata.asc
kv103m1.asc
kv6_ii.asc		-- Michael
lerpp1.asc (A weird Microsoft version of MIDI)
lmg-pdam.asc
lolimp4.asc
lpop11.asc
lpop1.asc
marbsnf4.asc
mcl373_1.asc
mlf01.asc
mm208.asc
mm505.asc		-- Nico
mormorar.asc
mr129_5.asc
mtaria3p.asc
mzalgk80.asc
niedo3b.asc
nina.asc
op5no1a_.asc
orchxg5.asc
plncmvtp.asc
pmpassep.asc		-- Rob
polkadwr.asc
ramns10.asc
rositalg.asc
rv780_2.asc
rwloa3p.asc
scri4201.asc
sib2-2.asc
simplcom.asc
slavdnce.asc
spohr80b.asc		-- Max
ssfe.asc
sstud15.asc
strsonat.asc
suite2-3.asc
sybije06.asc
sy_sps94.asc
telviol.asc
usehtul.asc
valselen.asc
variaz.asc		-- Eleanor
viv_laud.asc
wamk521.asc
water02.asc
water08.asc
water16.asc
wherwalk.asc
wmsingpr.asc
wobouv.asc
zenpmc3.asc












Revised: 15 Feb 2005