Spring 2018»CITA 180 Homework 3

CITA 180 Homework 3

Assigned Date: Monday, Feb. 5, 2018
Due Date: Monday, Feb. 12
Due Time: 30 mins before class

Last modified on February 10, 2018, at 06:42 AM (see updates)


Write a Jython program that generates an interesting piece of music using pre-recorded sound material.

The piece should utilize up to seven different AudioSamples. Each file should be up to 12 seconds - no more.

These samples will be used as instruments to Play a particular score that you will put together (see example below).

The piece should be somewhere between 1 to 3 minutes long approximately.


  • For polyphony, it is OK to load multiple copies of the same audio file - these do not count as separate files (for the total of seven).
  • Before spending too much time on your score, make sure your computer's CPU and memory can handle all the audio files you are planning to use.


Do all four:

  1. Draw a sketch of your score on paper (by hand or otherwise).
  2. Upload your program file and audio files on OAKS.
  3. Hand in a printout of your Python program in class on the due date. Attach the sketch of your score.
  4. Be ready to perform it in class.

Your program should have a meaningful name, e.g., birdsAndSeaguls.py or desertMoon.py, or nightAlone.py, etc.

Program Documentation

Follow the documentation instructions from Homework 1.

In addition, your header documentation should describe the following [1]:

  1. Initial, high-level concept (i.e., what is this piece about, what is it trying to communicate / achieve, etc.).
  2. Sonic entities used and their symbolism (i.e., mention something about each recording - what it is, how it was recorded, why did you include it, etc.). It is OK to use someone else's material, as long as you provide a name and URL where it can be found.
  3. Macrocomposition or high-level structure of the piece (i.e., how you set up relationships between sonic entities, such as algebraic operations to make sonic entities line up, etc.)


[1] Xenakis, I. (1971). Formalized Music: Thought and Mathematics in Composition. Indiana University Press, p. 22.


For extra points, you may explore the microcomposition or low-level interactions of the sonic elements (i.e., creating or assembling complex timbres from the sonic material).


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


Here are three examples that demonstrate the mechanics of this assignment (but not the inspiration - that's up to you).

Example No. 1

The following demonstrates how to do polyphony with a single audio file.

It utilizes the following sonic material (download and save in your JythonMusic folder prior to running):

  • sey.wav (a backwards "Yes", recorded during class)
from music import *

# load audio instruments
a1 = AudioSample("sey.wav")
a2 = AudioSample("sey.wav")
a3 = AudioSample("sey.wav")

# create musical data structure
score = Score()

part1 = Part(0, 0)
part2 = Part(0, 1)
part3 = Part(0, 2)

phr1 = Phrase()
phr2 = Phrase()
phr3 = Phrase()

# create musical data
pitches1   = [A4,  B3,  CS4]
pitches2   = [E4,  GS4, A4]
#pitches3   = [CS4, E4,  E4]
pitches3   = [CS2, E2,  E3]

durations  = []   # durations are in seconds (assuming 60bpm)

phr1.addNoteList(pitches1, durations)
phr2.addNoteList(pitches2, durations)
phr3.addNoteList(pitches3, durations)



# play it!
Play.audio( score, [a1, a2, a3] )

Example No. 2

The following demonstrates how to work with two different audio files, and also control their volume.

It utilizes the following sonic material (download and save in your JythonMusic folder prior to running):

Also, do realize that your sound material plays a major role in helping shape your aesthetic outcome. For example, for a more soothing effect, change the following to use these (you may have to adapt some parameters, i.e., pitch, duration, volume, and panning.):

from music import *

# load audio instruments
a1 = AudioSample("whatSouldISayIHaveNoIdea.wav")
a2 = AudioSample("Ricochet Of A Bullet-SoundBible.com-377161548.wav")

# create musical data structure
score = Score()    # 60bpm

part1 = Part(0, 0)
part2 = Part(0, 1)

phrase1 = Phrase()
phrase2 = Phrase()

# create musical data
pitches1   = [REST, A4]
durations1 = [1.66.0]
dynamics1  = [0,    127]

pitches2   = [A4,  REST, G2]
durations2 = [2.0, 1.812.2]
dynamics2  = [200,    60]   # lower volume of ricochet

# assemble musical data
phrase1.addNoteList(pitches1, durations1, dynamics1)
phrase2.addNoteList(pitches2, durations2, dynamics2)



# now, play it!
Play.audio( score, [a1, a2] )

Example No. 3

Here is the Autumn Leaves example, with a not-so-serious choice of audio instruments. (Also compare with the original.)

It utilizes the following sonic material (download and save in your JythonMusic folder prior to running):

# autumnLeaves_AudioPlay.py
# It plays the theme from "Autumn Leaves", in a Jazz trio arrangement
# but using actual audio files as instruments.
# NOTE: This is just an example of possibilities (and a bit tongue-in-cheek).
# (For your submission, follow full documentation instructions.)

from music import *

##### load sonic material
a = AudioSample("moondog.Bird_sLament.wav", G4)          # a loop from Moondog's "Bird's Lament"
b = AudioSample("It_s_Real_Easy.wav", BF2)               # a funny voice recording
c = AudioSample("Korg-TR-Rack-Acoustic-Bass-C2.wav", C2) # an actual bass sample

##### define the data structure (score, parts, and phrases)
autumnLeavesScore = Score("Autumn Leaves (Jazz Trio)", 140) # 140 bpm

trumpetPart = Part(TRUMPET, 0)       # trumpet to MIDI channel 0
vibesPart  = Part(VIBES, 1)          # vibraphone to MIDI channel 1
bassPart    = Part(ACOUSTIC_BASS, 2) # bass to MIDI channel 2

melodyPhrase = Phrase()   # holds the melody
chordPhrase  = Phrase()   # holds the chords
bassPhrase   = Phrase()   # holds the bass line

##### create musical data
# melody
melodyPitch1 = [REST, E4, FS4, G4, C5, REST, D4, E4, FS4, B4,  B4]
melodyDur1   = [QN,   QN, QN,  QN, WN, EN,   DQN,QN, QN,  DQN, HN+EN]
melodyPitch2 = [REST, C4, D4, E4, A4, REST, B3, A4, G4, E4]
melodyDur2   = [QN,   QN, QN, QN, WN, EN,   DQN,QN, QN, 6.0]

melodyPhrase.addNoteList(melodyPitch1, melodyDur1) # add to phrase
melodyPhrase.addNoteList(melodyPitch2, melodyDur2)

# chords
chordPitches1   = [REST, [E3, G3, A3, C4], [E3, G3, A3, C4], REST,
                    [FS3, A3, C4]]
chordDurations1 = [WN,    HN,               QN,              QN,
chordPitches2   = [REST, [D3, FS3, G3, B3], [D3, FS3, G3, B3]]
chordDurations2 = [DHN,  HN,                QN]
chordPitches3   = [REST, [C3, E3, G3, B3], REST, [E3, FS3, A3, C4],
                    [E3, FS3, A3, C4]]
chordDurations3 = [QN,   QN,               DHN,  HN,
chordPitches4   = [REST, [DS3, FS3, A3, B3], REST, [E3, G3, B3],
                   [DS3, FS3, A3, B3]]
chordDurations4 = [QN,   QN,                 DHN,  HN,
chordPitches5   = [REST, [E3, G3, B3], REST]
chordDurations5 = [QN,   HN,           HN]

chordPhrase.addNoteList(chordPitches1, chordDurations1)  # add them
chordPhrase.addNoteList(chordPitches2, chordDurations2)
chordPhrase.addNoteList(chordPitches3, chordDurations3)
chordPhrase.addNoteList(chordPitches4, chordDurations4)
chordPhrase.addNoteList(chordPitches5, chordDurations5)

# bass line
bassPitches1   = [REST, A2, REST, A2, E2, D2, REST, D2, A2, G2, REST,
                   G2, D2, C2]
bassDurations1 = [WN,   QN, EN,   EN, HN, QN, EN,   EN, HN, QN, EN,
                   EN, HN, QN]
bassDurations2 = [EN,   EN, HN, QN,  EN,   EN,  HN, QN, EN,   EN, HN,
bassPitches2   = [REST, C2, G2, FS2, REST, FS2, C2, B1, REST, B1, FS2,
bassPitches3   = [REST, E2, E2, B1, E2, REST]
bassDurations3 = [EN,   EN, QN, QN, HN, HN]

bassPhrase.addNoteList(bassPitches1, bassDurations1)  # add them
bassPhrase.addNoteList(bassPitches2, bassDurations2)
bassPhrase.addNoteList(bassPitches3, bassDurations3)

##### combine musical material
trumpetPart.addPhrase(melodyPhrase) # add phrases to parts

autumnLeavesScore.addPart(trumpetPart) # add parts to score

# play it 
#Play.midi(autumnLeavesScore)  # play music

Play.audio(autumnLeavesScore, [a, b, c])   # new way!

Note: The above utilizes chords, but has not accounted for polyphony. See warning and how to fix this.