Overview
In this assignment, students generate sound waveforms from scratch, starting with simple examples (sine waves, sawtooth waves, chords), and ending with an exploration of the strange and haunting world of fractal sounds.
In my course, I frame this assignment as an exploration of the idea of data compression. In lecture, we discuss ideas like run length encoding and Huffman coding, and I point the fact that for any stream of bits, there exists some shortest Java program that outputs those bits. This assignment demonstrates this in a visceral way.
The core idea for this assignment is that students built different implementations of the Generator interface, shown below:
public interface Generator { /** Returns a number between 1 and 1 */ double next(); }
Implementations of Generator include SineWaveGenerator, SawToothGenerator, AcceleratingSawToothGenerator, and StrangeBitwiseGenerator.
The assignment starts by introducing them to the provided very simple API that lets them visualize and audibilize the output of their generators.
SineWaveGenerator is given to students, and SawToothGenerator and AcceleratingSawToothGenerator are puzzles for them to implement. They also use our API to play three sine waves at once, generating a major chord. After completing these challenges, we guide them directly towards implementation of the StrangeBitwiseGenerator, which makes surprisingly complex, musical sounds using bitwise operations.
We then turn students lose to tinkering with the `StrangeBitwiseGenerator`, which can be done with no specific expertise or even understanding of bitwise operations.
Goals
My version of the assignment covers the following goals, in decreasing order of importance: Exposing students to a surprisingly rich, hidden programming domain.
 Inheritance and OOP.
 Using the modulus operator and bitwise operations.
Materials
Specification for this assignment: LinkStarter files (Java): Link
Metadata
Summary 
Students create code that generates sound waveforms, including fractal sound 
Topics 
OOP, bitwise operations, Data compression, sound synthesis 
Audience 
Late CS1, CS2 
Difficulty 
Easy to moderate. This was used as a 2 hour lab.

Strengths 

Weaknesses 

Library Dependencies 
Requires some sort of graphing library (provided: xChart) and sound playing library (provided: Princeton's StdAudio) 
Variants 
This assignment is built for variation. The sky is the limit as far as what they can build and achieve. Could also be adapted to be an intro assignment for bitwise operations. You can give them more complex waveforms that require the use of bitwise operations to efficiently match. 