I545/N364/N564 ASSIGNMENT: HISTOGRAM OF TIMINGS FOR A MIDI FILE Donald Byrd, 1 Feb. 2008 (rev. 3 Feb.) This assignment is to calculate and graph the distribution of note attack (onset) times within the measure for a given MIDI file. We'll use this music. http://www.informatics.indiana.edu/donbyrd/Teach/StdMusic/Schumann_Dichterliebe01.mid That's a MIDI file of the first song from Schumann's wonderful song cycle, Dichterliebe; it's for voice and piano. (The MIDI file is, I'm afraid, far from wonderful. Oh well.) You can find a PDF of the notation (as well as the MusicXML form, which we'll be talking about later) at http://www.recordare.com/xml/samples.html . For this assignment, we're interested only in the voice part. I've already converted the MIDI file to a text form that's much easier to handle in R, and removed the stuff we're not interested in. (FYI, I started by converting the whole MIDI file to text with a program by Prof. Eric Isaacson of the Music Theory Department, but these days I'd recommend a program by John Bowker, listed in my "Information Sources".) The text file is at: http://www.informatics.indiana.edu/donbyrd/Teach/StdMusic/Schumann_Dichterliebe01MIDT.txt In general, each line of the text file contains five fields, separated by tabs: 1. Cumulative time (time since the beginning of the track) 2. Delta time (time since the previous event) 3. Status byte 4. Data bytes 5. Description Of course we need to ignore the piano, as well as Note Off events and everything else other than Note Ons; that's also been done for you. So, how to read the file and access the timing information we want? After setting R's working directory to whereever you put the file, use the read.table function to read all its data in: noteTable = read.table("Dichterliebe01PMIDI.txt", header=TRUE) Then you can access the vector that contains the MIDI note numbers with either 'noteTable$Cum.time' or 'noteTable[1]'. (No, the "." in "Cum.time" won't confuse R.) This MIDI file has 1024 "ticks" per quarter note, which is 256 per 16th. The song is in 2/4 time, so a measure lasts 2048 ticks. However, there's a 16th-note pickup at the beginning, so the first full measure starts at 256 and ends at 2204. Therefore, a note that starts at time t has attack time within its measure of (t-256) modulo 2048. Have your program compute the number of occurrences of each measure-relative attack time for the entire melody, and plot the result. E-mail the program to me.