I’m Michael Phelps

September 11, 2008

This Processing Applet allows you to be Michael Phelps.
To run it, you will need to download Processing and the ESS library (from Processing.org), and the two PNG image files I used. The program will use the microphone on your computer.



**********************************************

// Input FFT
// original code by Marius Watz
// modified by Krister Olsson

// Showcase for new FFT processing options in Ess v2.
// Clicking and dragging changes FFT damping

// Created 27 May 2006

import krister.Ess.*;

int bufferSize;
int steps;
float limitDiff;
int numAverages=32;
float myDamp=.1f;
float maxLimit,minLimit;

PImage phelps;
PImage phelpsjaw;

FFT myFFT;
AudioInput myInput;

void setup () {
size(600,600);
phelps = loadImage(“phelps2.png”);
phelpsjaw = loadImage(“phelpsjaw.png”);

// start up Ess
Ess.start(this);

// set up our AudioInput
bufferSize=512;
myInput=new AudioInput(bufferSize);

// set up our FFT
myFFT=new FFT(bufferSize*2);
myFFT.equalizer(true);

// set up our FFT normalization/dampening
minLimit=.005;
maxLimit=.05;
myFFT.limits(minLimit,maxLimit);
myFFT.damp(myDamp);
myFFT.averages(numAverages);

// get the number of bins per average
steps=bufferSize/numAverages;

// get the distance of travel between minimum and maximum limits
limitDiff=maxLimit-minLimit;

myInput.start();
background(0);
image(phelps, 150,65);
}

void draw() {

int interp=(int)max(0,(((millis()-myInput.bufferStartTime)/(float)myInput.duration)*myInput.size));

for (int i=0;i<bufferSize;i++) {
float left=160;
float right=160;

if (i+interp+120){
image(phelpsjaw, 280, myFFT.spectrum[i]*100+ 290);
}
else{image(phelpsjaw, 280, 310);
}

if(myFFT.spectrum[i]*100+290>315){
image(phelps, 150,65);
}
}
}

public void audioInputData(AudioInput theInput) {
myFFT.getSpectrum(myInput);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: