Project 02: Face 2

by admin @ 12:11 pm August 31, 2011

For this assignment, you’ll add sound-interactivity to your face using the Minim audio library.

Check and see if Minim is already installed (under Sketch->Import Library).
If not, you’ll need to download and install Minim, from the location:

Your Processing project will have two files.
The first, main app file will be:


void setup(){
void draw(){
  // Draw the mouth.
  getVolume(); // this call fetches the mic volume for the current frame.
  float Y = map(volume, 0,100, 2,120);  // now we can use it for something!
  ellipse(200,200, 100,Y); 
  // The rest of the code just draws the Eye:
  float ex = 200;
  float ey = 100;
  ellipse(ex,ey, 60,60);
  float dx = constrain((mouseX-ex)/20, -14,14);
  float dy = constrain((mouseY-ey)/20, -14,14);
  ellipse(ex+dx,ey+dy, 20,20);

Now click on the little (+) to create the second file, which will get its own tab.
Name this file MyAudioHandler.pde, and input the following text. Don’t otherwise change this code:

// Don't worry about understanding the stuff below!
import ddf.minim.*;
Minim minim;
AudioInput in;
float volume = 0;
float volumeF = 0; 
void setupAudio(){
  minim = new Minim(this);
  in = minim.getLineIn(Minim.MONO, 512);
void getVolume(){
  volumeF = in.right.level()*1000;
  volume = 0.8*volume + 0.2*volumeF;
void stop(){

Please note that the resulting app will not work in a browser because of security restrictions. That’s OK.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2019 CMU Electronic Media Studio II, Fall 2011, Section A | powered by WordPress with Barecity