CSE 466 Lab 6:
Sound on the iMote 2 and SuperBird


In this lab, you will explore the sound generation capabilities of the SuperBord board. You will begin by writing a program to read and play back sampled audio files. Then, you will implement a simple synthesizer using a sine table and ADSR amplitude envelopes.

The last part of this lab is left open-ended to allow you to come up with a creative application for your synthesizer.

WARNING: NEVER attach or detach the iMote2 from the debug board or the sensor board when power is attached. ALWAYS make sure you've unplugged ALL of the USB cables when connecting or disconnecting the sensor board, debug board, or SuperBird.


In this lab, you will learn:

Suggested Reading and Resources

Part 1: Getting started with the Superbird

Obtain a Superbird board from a T.A. The Superbird board adds several peripherals to the iMote2 via the advanced connector on the iMote2. One of these peripherals is an audio codec with an on-board speaker.

Part 2: Sampled audio playback

For this part of the lab, you will implement playback of sampled audio files in .au format.

  1. Download the auplay starter code. The zip file contains:
  2. Add code to auplay.c that accepts the name of a .au file as an argument, reads the header from the audio file, and prints out the encoding (format), sample rate, and number of channels for the recording.
  3. Refer to the OSS API documentation section on the ioctl() system calls. Modify your program to open /dev/dsp as a write-only device and use ioctl() calls to set up the sound device for an encoding (format), sample rate, and number of channels that matches the information in the header of the audio file you're reading.
  4. Once your program has successfully opened the audio device and set the appropriate format parameters, read the rest of the data in the audio file and copy it to the sound device using the write() call. The OSS API does not specify the buffer size you should use when writing to the audio device. You should choose a size that is reasonable; i.e. you should be copying more than a single sample on each write, but you should not attempt to copy the entire audio file at once.

Part 3: Sine table synthesis

In this part of the lab, you will design a synthesizer that uses a table-based oscillator.

  1. The sin() function in math.h implements the sine function for angles in radians with floating-point arithmetic. Since the support for floating point numbers is limited on the iMote2, you should precalculate the sine table on attu and compile it into your synthesizer. You should write a C program that you can run to produce the table for you.
  2. Now that you have your fixed-point sine table, write a program that uses it to generate continuous tones.
  3. Next, write another program to run on attu that will generate another table containing an amplitude envelope. Like your sine table generator, this program should produce a valid .c file containing the table in an array that you can include in your synthesizer.
  4. Modify your synthesizer to apply your amplitude envelope to the generated sound. You should use a separate counter for the envelope table, and make sure that you stop producing sound when you reach the end of your envelope.

Part 4: Do something interesting with your synthesizer

At this point, you should have a working synthesizer that generates sounds from a sine table and applies an amplitude envelope. Now's your chance to be creative and extend your synthesizer program to do something with the sounds it can generate.

Extra Credit: Implement FM synthesis

For extra credit, you can add a second oscillator and generate sounds via frequency modulation synthesis. See this PDF for some examples.


Turn in all required documents via Catalyst, or as an e-mail attachment to cse466-tas@cs. For all files turned in, the comments at the top of the file should contain:

  1. Demonstrate your .au player and your synthesizer to a T.A. You can either do this during lab, or during the first 1/2 hour of the next lab.
  2. At the end of the second week, you should turn in source files for: You should create a .zip or .tar archive of all of the files you are turning in.