Difference between revisions of "MIDI file parsing homework"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
== Assignment == | == Assignment == | ||
− | # Find a MIDI file on the web. Tip: include <em>[https://www.google.com/search?q=filetype%3Amid&lr=lang_en filetype: | + | # Find a MIDI file on the web. Tip: include <em>[https://www.google.com/search?q=filetype%3Amid&lr=lang_en filetype:midi]</em> when searching for MIDI files in Google searches. |
# Save the MIDI file to your desktop and open it (usually double-clicking to open with the default MIDI playing program on your computer). | # Save the MIDI file to your desktop and open it (usually double-clicking to open with the default MIDI playing program on your computer). | ||
# If it plays correctly, drag and drop the MIDI file from your desktop onto the [http://www.ccarh.org/software/binasc binasc online] webpage. | # If it plays correctly, drag and drop the MIDI file from your desktop onto the [http://www.ccarh.org/software/binasc binasc online] webpage. |
Revision as of 04:35, 21 January 2016
Assignment
- Find a MIDI file on the web. Tip: include filetype:midi when searching for MIDI files in Google searches.
- Save the MIDI file to your desktop and open it (usually double-clicking to open with the default MIDI playing program on your computer).
- If it plays correctly, drag and drop the MIDI file from your desktop onto the binasc online webpage.
- Parse the resulting display of the MIDI file's hexadecimal bytes by hand. Make note of the number of tracks in the file; whether it is type-0 or type-1 (or type-2), and how many ticks per quarter note (or SMPTE frames/subframes) are used for basic timing in the file.
- Parse at least 25 time/message pairs in one of the tracks of the MIDI File. Note that type-1 files only stores meta messages such as tempo changes in the first track. If your file is a type-1 file, try parsing a few of these meta messages, and then switch to another track with notes.
- Give the basic meaning of MIDI messages (such as this is a note-on messages for pitch A4, or this is a tempo meta message).
- Decoding VLVs for delta timings is optional.
- Extra Credit: Write your own Standard MIDI File parser which will do this homework for you.
- Email MIDI file and your parsing to you know who.
Example
Here is the simple example done in class using File:Twinkle.mid. Converting bytes into a list of hexadecimal numbers with binasc online:
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
Example parsing to be done by hand (don't worry about unpacking VLV timestamps), or write your own extra-credit MIDI file parser:
4d 54 68 64 MIDI header chunk marker ("MThd")
00 00 00 06 Bytes to follow in header chunk (6) 00 00 file format: Type-0 (0 == single track format) 00 01 number of tracks (1) 00 80 ticks per quarter note (128) First (and only track): 4d 54 72 6b MIDI track chunk marker ("MTrk") 00 00 00 8c Bytes to follow in track chunk (140 bytes) VLV MIDI message ============================================ 0 ff 58 '4 4 2 30 8 Meta-message for tempo 0 ff 59 '2 0 0 Meta-message for time signature 0 90 '60 '40 Note on, C4 128 90 '60 0 Note off, C4 0 90 '60 '30 etc. 128 90 '60 0 0 90 '67 '45 128 90 '67 0 0 90 '67 '50 128 90 '67 0 0 90 '69 '45 128 90 '69 0 0 90 '69 '50 128 90 '69 0 0 90 '67 '35 256 90 '67 0 0 90 '65 '50 128 90 '65 0 0 90 '65 '45 128 90 '65 0 0 90 '64 '50 64 90 '64 0 64 90 '64 '40 64 90 '64 0 64 90 '62 '45 64 90 '62 0 64 90 '62 '50 64 90 '62 0 64 90 '60 '30 256 90 '60 0 0 ff 2f 0 Meta-message for end-of-track