Spring 2010»CSCI 180 Homework 3

CSCI 180 Homework 3

Assigned Date: Thursday, Mar. 25, 2010
Due Date: Thursday, Apr. 1, 2010
Due Time: 9:20am

Last modified on April 09, 2010, at 05:06 PM (see updates)

This is a pair-programming assignment (i.e., you may work with one partner). You may discuss the assignment only with your partner or the instructor.


This assignment focuses on:

  • creating interesting music with jMusic
  • MIDI melodies
  • MIDI percussion


In class we worked through several programs that put all jMusic data structures into practice (see Ch2 of the jMusic book). We looked at:

  • a program that creates a drum pattern consisting of kick, snare and hi-hat sounds;
  • a program that creates a cannon; and
  • a program that creates a minimalist piece (Piano Phase by Steve Reich).

As mentioned earlier, MIDI has 16 channels (numbered 0 to 15). Of these, channel 9 is reserved for percussion. When adding notes to a part assigned to channel 9, the pitch of the notes determines which percussive instrument to use. Again, here are pitch numbers for some percussive instruments:

  • 36 (C2) -- Bass Drum
  • 38 (D2) -- Snare Drum
  • 42 (FS2) -- Hi Hat (closed)
  • 46 (AS2) -- Hi Hat (open)
  • 49 (DF3) -- Crash Cymbal

Here are more pitch numbers for percussive instruments.


Write a Jython program that generates an interesting piece of music. You have two options:

  1. Find an interesting minimalist piece (e.g., by Philip Glass), and work with it in jMusic.
  2. Or, create your own song in jMusic. If so, the song needs to have both a melody and drums (all done in MIDI via jMusic).


Here is a quick overview of music notation for note pitches.

Rhythm Values

Here is a quick overview of music notation for note durations (rhythm values).

  • jMusic defines the following note durations for convenience.
    • It includes both American and British names. For example,
      • whole note = semibreve
      • half note = minim
      • quarter note = crochet
      • eighth note = quaver

MIDI Instruments

jMusic provides the following MIDI Instruments.


Follow the Golden Rule of Style: "A program should be as easy for a human being to read and understand as it is for a computer to execute." [2]

In general, you should comment any variable, obscure statement, block of code, etc. you create.

Your comments should express why something is being done, as opposed to how the how is shown by the code.

Additionally, your code should always include opening comments as follows:

#   Author:     <Your Name(s)>
#   Email:      <Your email address(es)>
#   Class:      CSCI 180, Section 1
#   Assignment: HMWK2
#   Due Date:   <The assignment's due date>
#   Certification of Authenticity <remove one of the following>:     
#      I certify that this lab is entirely my own work.
#      I certify that this lab is my own work, but I received
#      some assistance from:  <Name(s)>
#   Purpose: <Provide a simple, yet complete description of the task being
#         performed by this program. It may be several sentences long.>
#   Input: <Provide a simple, yet complete description of the input required
#               by this program.>
#   Output: <Provide a simple, yet complete description of the output generated
#          by this program.>


You will submit your assignment via WebCT. Be prepared to demo your music to the rest of the class. Your submission consists of:

  1. Your Python program. Give it a meaningful name.


Your grade will be based on how well you followed the above instructions, and the depth/quality of your work.

A Few Interesting Submissions

There were several great submissions. Here are four that stood out: (regardless of grade earned - grading depended on more than just sound)

  1. Bayside (MIDI and Python), by Jacob Lilley
  2. Three Cheers for My Five Years Parade (MIDI and Python), by Katy Lawrimore
  3. Dvorak Sonata (MIDI and Python), by Nicholas Capps
  4. Cars Fighting in the Night (MIDI and Python), by Douglas McNellis

Relevant Quote

"Any amount of work can be done in any amount of time... only the quality varies." ~Joao Meidanis


  1. Cooper, D. and Clancy, M. (1985) "Oh! Pascal", 2nd ed., W.W. Norton & Company, New York, p. 42.