Digital Sound Processing

Daniel Zingaro - University of Toronto

There are lots of nifty assignments that do cool things with images (encryption, animation, manipulation, and so on). Here, instead, is an assignment exclusively based on digital sound. (This assignment is also known as the Digital Sound Processing assignment -- daniel's site)

At the University of Toronto, our CS1 course is taught using Python. We use a locally modified media library derived from Mark Guzdial's Introduction to computing and programming with Python: A Multimedia Approach. The sound media module I supply with this assignment is our media module restricted to the sound-related features.

In this assignment, students implement some simple filters on sound objects, including reversing a sound, mixing arbitrary-length lists of sounds, adding echoes to sounds, and changing volumes of sounds. These functions can each be written in ten or fifteen lines of code, using objects that represent sounds and samples from our media module. Then, calling on these functions, students write a "song generator": a function that takes a string of note data (a notestring) and produces its representative sound object that can be played or saved as a wav file. I provide sample notestrings that demonstrate various features of notestrings, as well as notestrings of songs that students know. When they can play these and listen to the music, they know they've done something right!

Summary Applying filters to wav files, and parsing strings of notes into recognizable melodies.
Composing functions, manipulating sound data, loops, and simple string parsing.
Early-to-mid CS1.
Intermediate difficulty, assuming this is students' initial exposure to string processing.
The end result is a parser for a simple note "language"; students get to play with sample notestrings and hear reasonably complex and familiar tunes. Students also get to add effects to sound files; many are familiar with such effects from sound-processing software.
There is a considerable amount for students to absorb; students must be comfortable with basic control structures, as well as be able to learn about and use functions from our media module. I feel it fits best as a second or third assignment in the course.
Requires a sounds package that gives access to individual samples of sounds, and functions for generating the notes of the C scale. By providing the latter functionality, students are not exposed to the mathematical functions that are sampled to generate the notes.
One can imagine adding further complexity to the notestrings. My notestrings do not support sharps and flats, or dotted notes. (If such features were added, students could parse RTTL cell phone ringtones.) Additionally, students could build a commandline or GUI interface for supplying notestrings and listening to the results.

Assignment Handout

Presentation Slides

Here are my Nifty Presentation Slides from SIGCSE 2010.


The Sound Media module used by the students to complete this assignment has been tested with, and requires, the following:

Last modified: 2011-03-14

Extra info about this assignment: