From CCRMA Wiki
Jump to: navigation, search

Homework #1: iPhone Programming Lab: Audio + Interaction

Due date: 2011.1.12 11:59:59pm (or thereabout), Wednesday.


The goal of the first homework is to set up real-time audio on the phone, and explore basic interactions with input from the accelerometer, multi-touch, or GUI elements. Let's get cookin'.

Specification (part 1 of 3): Get Set Up

  • set up your development environment (XCode, have your development device provisioned, installed the provision, etc.)
  • compile and run a standalone program and install it on your physical iPhone device:
    • create a new "View-based Application" project for iPhone (OS File-> New Project -> View-based Project) - name it as you like
    • compile and run on the device (not just in the simulator). Make sure the .plist file is correct (Bundle identifier= edu.stanford.ccrma.${PRODUCT_NAME}
  • make basic audio I/O work (this will be covered in class and in tutorial)
    • use mo_audio.* to set up an audio callback, and initialize it (see MoMu Toolkit
    • create the audio callback, and populated the buffer, e.g., synthesize a simple sine wave to fill in the output buffer (if you do not do anything in the audio callback loop, feedback will most likely result.)
    • test it
    • this should be covered in class, and reviewed from the tutorial.

Specification (part 2 of 3): Real-time Audio Synthesize

  • based on the code above, create three apps, one for each of the following:
    • a sine wave
    • FM synthesis tone
    • a delayed version of the audio input (set up a circular buffer, as in hw2 from 256a)
  • be mindful of the parameters for each of these synthesis methods (and be ready to expose and chance them in section 3 below).

Specification (part 3 of 3): Exploring Interaction

  • for the respective apps, connect synthesis parameters to interactions as follows:
    • (app #1) sine wave: connect the first axis of the accelerometer to the frequency
    • (app #2) FM synthesis:
      • connect the first two axes to carrier and modulator frequencies (you determine the ranges), and add a GUI element (e.g., slider) to control the modulation index.
      • add a toggle (UISwitch) between a) continuous audio output and b) manually triggered notes
      • for the latter (manually triggered notes), add a GUI button to trigger the notes.
    • (app #3) delayed input: use multi-touch and the two-point pinch gesture to control delay length (you may add another slider to control the feedback coefficient, and a label to output the current delay length)
  • even though this assignment is intended to familiarize you with audio + interaction on the phone, consider the aesthetic and user experience.


  • make a delayline class of some sort
  • figure out a simple way to slew control parameters to eliminating audio clicks and glitches
  • use a simple counting mechanism or envelope generator to trigger notes on and off--possibly in a separate class
  • make things as simple as possible...Global variables are fine for now.


  • have fun with it!!!
  • comment your code!
  • choose your own coding conventions - but be consistent
  • you are welcome to work together, but you must do/turn in your own work


turn in all files by putting them in your Library/Web/256b/hw1/ directory, and concise online documentation + readme - emailing ge (ge), jieun (jieun5), and nick (nkruge)

  • 1) source code to the project(s) (*.h, *.cpp, *.m *.mm *.c makefile, project files, etc.)
  • 2) online page for your project (should be viewable at http://ccrma.stanford.edu/~YOURID/256b/hw1/). It should include:
    • links to your files of various kinds (or to a zip/tar archive)
    • instructions on building the project (for example, anyone in the class should be able to download and run)
    • a short README text section that:
      • conveys your ideas/comments in constructing each program
      • describes any difficulties you encountered in the process
      • lists any collaborators
  • 3) email Ge, Jieun, and Nick with the link to your web page, as a confirmation that you are submitting the assignment