Fall 2011»CSCI 180 Homework 3

CSCI 180 Homework 3

Section 1:

Assigned: Friday, Oct. 21, 2011
Due Date: Monday, Oct. 31
Due Time: 10:50am

Section 2:

Assigned: Thursday, Oct. 20, 2011
Due Date: Tuesday, Nov. 1
Due Time: 9:20am

Last modified on October 27, 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.

Planets and the Golden Ratio

Using Bode's law, it has been shown that "the orbital data of all planets, asteroids, moons, and rings in the solar system reduce to a simple numerical pattern based on the golden ratio. A set of integers, not unlike the quantum numbers of atomic systems, defines the mean orbits of all planets and major satellites." [2]


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 = int((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.

Alternatively, we could use the jythonMusic mapValue() function. This function expects as arguments the value to be mapped, the smallest and largest possible value to be mapped, and the smallest and largest values of the destination range:

pitch = mapValue(velocity, minVelocity, maxVelocity, 30, 120)


  1. Make your program do all the necessary calculations. In other words, your program should include the formula that generates each pitch. Make your program do all the work (as opposed to you doing some of the calculations (e.g., in the Python interpreter, or via a calculator) and then using the numeric results in the program).
  2. Do include Ceres (i.e., the asteroid belt) and Pluto.
  3. Make sure you initialize each of the above variables appropriately.
  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." [3]

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. Jan C. A. Boeyens, "Commensurability in the solar system", Physics Essays, 22(4), pp. 493-500, Dec. 2009.
  3. Cooper, D. and Clancy, M. (1985) "Oh! Pascal", 2nd ed., W.W. Norton & Company, New York, p. 42.
  4. Enchanted Learning.com, "The Planets (plus the Dwarf Planet Pluto)", Accessed on-line, Feb. 17, 2010.
  5. Olivier Messiaen, "Mode de valeurs et d'intensités" for piano (1949).

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)