Multimodal Media Madness - Winter Semester 2004/2005

Assignment 3 - Java Sequencer
Due on Monday, November 15, 2004 @noon


In this assignment, you will examine the MIDI protocol and the basic MIDI file format in more depth.

If you are not yet up to speed on Java programming, we highly recommend you review some basic Java programming tutorials.


Your assignment for the week is to create a Java program that does something similar to your first Max sequencer from last week. In particular, your program must at least be able to:
  • Play a MIDI note through SimpleSynth when you tap a key on the keyboard.
    • Users of your program should at least be able to play one full octave using the keyboard. The suggested mapping for the keyboard -> piano keys is z/y, x, c, v, b, n, m for the white keys and s, d, g, h, j for the black keys.
    • The note should be played for one second on each press of the keyboard (for bonus marks, make it such that the note plays for as long as the user holds down the key).
  • Use the number keys 0-9 to select an instrument.
  • When you press the spacebar, the program should take your input and record it to a MIDI file. The program should stop recording when you press the spacebar again. This MIDI file should play correctly in QuickTime. You do not have to keep track of the timing information or any program changes -- just record each note one by one, spaced evenly apart to the MIDI file.

Please note the following:
  • When communicating to SimpleSynth via MIDI, you must compose the MIDI messages yourself manually. Do not use the built-in APIs for sending note on/off messages or program changes.
  • Likewise for writing out to a MIDI file, you must write the code for outputting a MIDI-compatible file yourself, without using any third-party libraries/source code. For this assignment, it is enough to create a single-track MIDI file.
  • Be sure to comment your code! If we cannot understand what you are doing, you will lose marks (especially if your code doesn't work as expected)

Hints and Tips:
  • You must start SimpleSynth if you wish to hear sound. (Use this instead of GarageBand).
  • You may find this specification of the MIDI protocol useful. We've also created a skeleton MIDI controller class to get you started (this class uses Apple's CoreMIDI API's, and will most likely not work on anything other than a Mac).
  • The MIDI file format is described in various places:, This description is a good start. We've also created a sample MIDI file which contains 3 evenly-spaced notes (C, D, E) for reference.
  • We recommend using the FileOutputStream class for writing out binary files (do not use FileWriter as it passes your input through a virtual character translation table).
  • MIDIMonitor is a useful debugging tool to see what kind of MIDI messages are being sent around the system.
  • HexEdit is a good tool for looking at the contents of binary files. You may find it useful for debugging your MIDI files.
  • To capture keystrokes, the easiest way is to probably create a Java Swing window and listen to keyboard events. No other GUI is required for this assignment.

To develop your program, you may use the command line Java tools or Eclipse, a popular Java IDE. If you are really feeling brave, you may also develop your program using XCode, Apple's IDE. You can launch a UNIX prompt by opening Applications -> Utilities -> Terminal.

This assignment is to be completed in groups of 2.

Some ideas for extra credit for this assignment:
  • make the MIDI note play for as long as you hold down the key on the keyboard
  • preserve timing information in your recording to MIDI file
  • support program changes in your recording to MIDI file
  • make a nice GUI
  • etc... (use your imagination!)


Email an archive of your assignment to This email address is being protected from spambots. You need JavaScript enabled to view it. before the due date. The subject of your email should be "M3 Assignment 3"; be sure to use this exact subject line as it will be used to filter assignment submissions for grading.

Your assignment archive should include all files required to compile and run your Java code. Do not include compiled object (.class) files. Include a short plain text README file that contains:
  • the names and email addresses of all group members
  • instructions on how to compile and run your code
  • a short description of what your program does
  • non-obvious things you did (if any)
  • if you did any extra credit work, be sure to tell us what you did

Be prepared to discuss your solution in the next lab.


The assignment will be graded on the following rough scale:
  • 1.0 - exceptional work that clearly went above and beyond what was given on the exercise
  • 2.0 - exercise was completed satisfactorily as per the assignment specification
  • 3.0 - exercise was completed, but has some problems
  • 4.0 - incomplete exercise
  • 5.0 - little or no effort was put into the exercise

Late assignments will be graded with a penalty of 0.5 per 24 hour period after the due date.

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.