ece481 | doering | ece labs | ece | rhit |
MIDI File WriterOverviewThe main idea of this project is to write a set of functions that will assist you to build the sequence of elements needed to make a complete MIDI file. The functions should return a row vector of integer values, so that concatenating a series of function calls will produce a single row vector corresponding to the numerical values that make up the MIDI file. Use ‘putbytes’ to write the row vector out to a file. MATLAB commands that may come in handy: double, dec2hex, hex2dec, dec2bin, bin2dec; putbytes, getbytes, hexdmp; also see help on strfun, iofun, and ops (for bitwise operators). DeliverablesOne-page memo detailing your results, plus additional attachments as needed. Be sure to include the following:
Part 1 – Chunk Preamble GeneratorsWrite a function that generates the header chunk preamble. The function should accept format type, number of tracks, and quarter note division as input parameters. Write another function to generate the track chunk preamble. It should accept track length as a parameter Part 2 – Decimal-to-VL Format ConverterWrite a function that accepts a decimal number and produces the variable-length format number Part 3 – Patch Select FunctionWrite a function that accepts a patch number between 1 and 128 and a MIDI channel number to produce the MIDI bank-select event codes to select a voice (patch). Part 4 – Meta-Event GeneratorsWrite a function that generates the “end-of-sequence” code. TIP: The end-of-sequence code is an event like any other, so remember to insert a delta time before the event. Write a function to generate the “set tempo” code. The function should accept an integer in units of microseconds. Part 5 – Note-On / Note-Off FunctionsWrite a pair of functions that generate note-on and note-off MIDI events, respectively. The functions should accept note number and velocity as input parameters. Part 6 – Delta-Time GeneratorWrite a function which accepts a delta-time in seconds and produces the delta-time sequence in ticks (variable length format, remember). Part 7 – Test DrivePull together everything you have written so far to generate a test file. For example, try an ascending scale of notes spaced 1 second apart. Use the Windows MediaPlayer (Start à Programs à Accessories à Entertainmentà MediaPlayer) to play the file. Does the timing work out correctly? You may find it helpful to troubleshoot your test file by using a hex editor such as XVI32. Of course, you can also use a combination of getbytes and hexdmp, too. Part 8 – Note List to MIDI Track ConverterWrite a function that accepts a note list (a matrix where each row contains a delta-time and note event) and produces an appropriate sequence for the track. The function should accept MIDI channel number in addition to the note list. Part 9 – The Real ThingWrite a simple composition that makes use of as many features as possible. Use at least two tracks, each with a distinct channel and voice. Experiment with single-note sequences, chords, note-on velocity, etc. Describe the goal of your composition. |
|