Spring 2011»CSCI 180 Homework 2

CSCI 180 Homework 2

Assigned Date: Wednesday, Mar. 30, 2011
Due Date: Friday, Apr. 8, 2011
Due Time: 8:55am

Last modified on April 04, 2011, at 09:22 AM (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 music with computers,
  • connections between numbers and music,
  • fundamentals of algorithmic composition,
  • MIDI notes, durations, etc., and
  • generating a MIDI file.


According to Scaletti [1],

[t]he idea of representing data in sound is an ancient one. For the ancient Greeks music was not an art-for-art's sake, practiced in a vacuum, but a manifestation of the same ratios and relationships as those found in geometry or in the positions and behaviors of the planets.

Johannes Kepler

In 1619 Johannes Kepler wrote his "Harmonices Mundi (Harmony of the Worlds)" treatise. While philosophers spoke of the "music of the spheres," Kepler discovered physical harmonies in planetary motion and is a key figure in the scientific revolution that brought us out of the dark ages.

Bode's Law

The Titius–Bode law (aka Bode's law) is an attempt to model the symmetries and proportions of our solar system. Actually, it predicted the asteroid belt between Mars and Jupiter (long before it was discovered), but fails to account of the irregularly moving Neptune and the (now demoted non-planet) Pluto.


Write a Jython program that generates a sonification of the planets' organization using the jMusic programming library for musicians. Your program should generate a MIDI file with your sonification.

In particular, convert the orbital velocities of the planets to MIDI notes:

  • Map the range of orbital velocities to the range of 30-120. Use the resulting numbers as MIDI pitches.

To do so, use the following formula:

pitch = ((velocity - minVelocity) / (maxVelocity - minVelocity) * 90) + 30

where velocity is the orbital velocity of some planet, minVelocity is the smallest orbital velocity among the planets, and maxVelocity is the largest orbital velocity among the planets.


  1. Do include Ceres (i.e., the asteroid belt) and Pluto.
  2. Make sure you initialize each of the above variables appropriately.
  3. Make sure you convert pitch to an integer (via the int() function) before using it to create a MIDI note.
  4. Feel free to experiment with other astronomical data from the planets.


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, method, and class you create.

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

Top Documentation

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 OAKS/Dropbox. Be prepared to demo your music to the rest of the class. Your submission consists of the following:

  1. Your Jython program (call it harmonicesMundi.py).
  2. Your MIDI file (call it harmonicesMundi.mid).


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

Relevant Quote

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


  1. Quote from Carla Scaletti, "Sonification - An Ancient Idea Made Feasible by New Technology", ACM SIGRAPH '93 - Course Notes 81, Aug. 1993, p. 4.2.
  2. Cooper, D. and Clancy, M. (1985) "Oh! Pascal", 2nd ed., W.W. Norton & Company, New York, p. 42.
  3. Enchanted Learning.com, "The Planets (plus the Dwarf Planet Pluto)", Accessed on-line, Feb. 17, 2010.

A Few Interesting Submissions

Here are three submissions from a previous semester (independent of grade earned - grading depended on more than just sound)

  1. Harmonices Mundi #1 (by Courtney Miller and Caitlin Altman)
  2. Harmonices Mundi #2 (by Douglas McNellis and Ian Fricker)
  3. Harmonices Mundi #3 (by Matthew Blough-Wayles and Shea McSween)