Spring 2006»CSCI 221 Homework 5

CSCI 221 Homework 5

Assigned Date: Thursday, Mar. 29, 2006
Due Date: Friday, Apr. 14, 2006
Due Time: 11:55pm

Check updates.

Last modified on April 13, 2006, at 11:10 AM (see updates)


This assignment focuses on Linked Lists.

You are expected to work in isolation (without access to any resources other than the class textbook, class notes, and the instructor).


Write a program to manipulate MIDI files.

To do so you will use classes from jMusic. jMusic is an API for sound and music applications in Java.

First you need to set up jMusic on your computer.


Your program should be implemented using BlueJ. Create a project called, Music. In that project create the following classes and methods:

  • Song
    • public Song() -- initializes internal data structure
    • public void readMIDI(String fileName) -- inputs a MIDI file
    • public void writeMIDI(String fileName) -- outputs a MIDI file
    • public void setSong(Score score) -- converts a jMusic Score to a song
    • public Score getScore() -- converts song to a jMusic Score
      (Hint: You might find Part.addNote() useful.)
    • public void addNote(ExtendedNote note) -- adds a note to the song
    • public void echo(double delay, int repeat) -- adds echo effect to song
    • public void reverb(int depth) -- adds reverb effect to song
    • public String toString() -- returns String representation of song
  • MusicMaker the system driver
    • public static void main(String[] args) - declares necessary instances of classes and uses their methods to make some demo music.

Internal Data Structure

You should use a linked list of notes to store the song.

This linked list should utilize class Node (given in class).

The info field of class Node should be of class ExtendedNote (to be provided).

Hint: To build your list, extract jMusic Note's from the input MIDI file, and store them in increasing order of start time within ExtendedNote's.

To find the Note objects, you need to get the Part objectss of the Score, then get the Phrase objects within each Part, then get the Note objects within each Phrase, and finally wrap each Note within an ExtendedNote. Start time is found within each Phrase.


  • public void play() -- plays song (Hint: use jMusic's Play class)
  • public void view() -- displays song (Hint: use jMusic's View class)
  • public void removeNote(ExtendedNote note) -- removes the first occurrance of note from song
  • public Score randomScore(int numNotes) -- returns a Score of numNotes notes with random pitch, rhythm value, and start time.

Super Bonus

Create additional Song effects (methods).

Demonstate your effects through MusicMaker. For each effect, it should create (at least) one meaningfully named .mid file. These files should be stored in the current directory (i.e., no "hardwired" path names).

Running MusicMaker should generate all demos at once (i.e., no editing required by instructor/grader).

Within Readme.txt document your extra work. No bonus if you omit this part!


Focus on functional cohesion, i.e., a method should implement only one bit of functionality. The smaller, the better.

Your methods should be fully documented via javadoc.


  1. Open your BlueJ project.
  2. Open (edit) each source file and generate the class interface (javadoc). This can be done within the editor window either by pressing CTRL/J , or selecting the Interface drop-down menu item (on the right). (Note: This is necessary to generate your documentation for grading.)
  3. Under the Project menu, click Create Jar File... . In the dialog box that opens, select Include Source, and press Continue.
  4. Verify that the .jar file is correct, by using the 'jar xvf file.jar' command, where file.jar is your archive. Your .jar file should contain:
    • Readme.txt (see Widget for a sample).
    • Any files generated automatically by BlueJ (e.g., bluej.pkg, bluej.pkh, etc.).
    • Song.java, MusicMaker.java, ExtendedNote.java.
  • A doc subdirectory with the Javadoc API documentation generated by BlueJ, for each of the classes above.

In other words, I should be able to unzip your submission and run it without modifications or additions.

  1. Email the generated .jar file to manaris@cs.cofc.edu, by the due date and time.
  2. In the same email, attach .mid files demoing your effects. For example, attach x.mid, x_echo.mid, x_reverb.mid, where x is a descriptive name of the music stored in the MIDI file (e.g., StairwayToHeaven.mid, StairwayToHeaven_echo.mid, StairwayToHeaven_reverb.mid).