Difference between revisions of "250a Accelerometer Lab"

From CCRMA Wiki
Jump to: navigation, search
(Naive Gesture Detection and Thresholding)
(Get the iPod talking to your computer via Open Sound Control)
Line 17: Line 17:
 
* On the iPod start TouchOSC and press the small 'i' to get to preferences. Select 'Network' and set Host to the name of your computer (e.g. 'cmn37.stanford.edu' or 'mylaptop.local'.)
 
* On the iPod start TouchOSC and press the small 'i' to get to preferences. Select 'Network' and set Host to the name of your computer (e.g. 'cmn37.stanford.edu' or 'mylaptop.local'.)
 
* Set the outgoing port to 8000.
 
* Set the outgoing port to 8000.
* Open accel_osc.pd (INSERT LINK AND MAX PATCH HERE), and make sure that accelerometer messages from TouchOSC are being received in Pd/Max.
+
* Open accel_osc, and make sure that accelerometer messages from TouchOSC are being received in Pd/Max.
 
* use printing to examine the incoming OSC messages.
 
* use printing to examine the incoming OSC messages.
  

Revision as of 12:42, 14 October 2009

Lab 4: Accelerometers, Audio Filters, and (optionally) Multitouch
Due on Wednesday, October 21th at 5PM

For this lab you need an iPod Touch (loaners are available) or an iPhone running TouchOSC, and Max/MSP or Pd on a computer.

Get Connected and Get Oriented

iPod Touches, like many newer portable electronic devices, have a 3-axis accelerometer in them, which allows designers to take into account both orientation of the device with respect to gravity as well as detecting physical gestures that are made with the phone.

For this lab, instead of writing our own iPod applications (the subject of an entire course), we will use an iPod app called TouchOSC to send accelerometer data from the iPod to max or pd, where we will process the data and make sound. TouchOSC is installed on the iPods available to use in this lab.

(If you prefer to use your own iPod or iPhone, you are welcome to use one of the other apps which perform similar functions. Here is a review of some options: http://heuristicmusic.com/blog/?p=124.)

Get the iPod talking to your computer via Open Sound Control

  • Make sure your computer and iPod are on the same network.
    • You may need to log your iPod into CCRMA Guestnet. To do this, open safari and try to access a new web page. If you can, you are logged in. If you can't you will be asked to login.
  • Find out the name or IP address of your computer.
  • On the iPod start TouchOSC and press the small 'i' to get to preferences. Select 'Network' and set Host to the name of your computer (e.g. 'cmn37.stanford.edu' or 'mylaptop.local'.)
  • Set the outgoing port to 8000.
  • Open accel_osc, and make sure that accelerometer messages from TouchOSC are being received in Pd/Max.
  • use printing to examine the incoming OSC messages.

Get Oriented

  • Look at the acceleration values and graphs as you move the iPod around.
  • What are the units that acceleration is reported in?
  • Figure out the direction and orientation of each (x,y,z) accelerometer axis. How do you do this?
  • Draw a picture of the x,y, and z axes and their orientation as they relate to the iPod. (For lab submission you can include this picture or describe verbally what you discover.)

Naive Gesture Detection and Thresholding

Here's a way to make a simple gesture detector. One obvious difference between fast jerky movements and slow gradual movements is sudden jumps in the acceleration values. As discussed in lecture, jerk is the derivative of acceleration.

Since our accelerometer data is discrete in time (i.e. we get one value every some number of milliseconds), we can approximate derivation by taking the difference between successive values. (Technically, this is a "one-zero highpass filter.") Look at the included delta abstraction, which simply returns the difference between subsequent input values.

After taking the difference you can detect when the difference is greater than some threshold.

  • Start with accel+osc.
  • In max you can use 'delta' to find the difference, and then 'past' to determine when you've passed the threshold.
  • In pd the object 'threshold' (or 'mapping/threshold' if it doesn't recognize 'threshold') takes the difference and thresholds.
  • Have your patch make a sound when the threshold has been surpassed.
  • You can give the user additional control of the sound based on the direction and/or the magnitude of the jerk, if you like.

Congratulations, you have now written a jerk detector.

Audio Filtering

The purpose of this part of the lab is to get a sense for the effect of different kinds of filters, and to start thinking about (audio) signals as being comprised of frequency components. Don't worry, we'll come back