:::: You first have to download Ess sound librairy [here] in order to play. The ellipse reacts to the sound input from the computer's microphone (arduino is not plugged yet). It accelerates and changes its diameter/stroke weight depending on the sound intensity ::::
import krister.Ess.*;
AudioInput entree_son;
FFT analyse_fft;
int buffer = 512;
float normalisation;
// cell behavior variables
color insideCell = color (100,100,200);
color outsideCell = color (100,150,255);
float x = 0;
float y = 100;
float widthA = 100;
float heightA = 100;
void setup() {
size(1000,600);
frameRate(1000);
// starts ess
Ess.start(this);
// get access to audio input
entree_son=new AudioInput(buffer);
// start audio analyzer
analyse_fft=new FFT(buffer * 100);
analyse_fft.equalizer(true);
// normalizing values
float min_limit=.005;
float max_limit=.05;
analyse_fft.limits(min_limit,max_limit);
analyse_fft.damp(.1f);
analyse_fft.averages(32);
normalisation = max_limit - min_limit;
// starts your engines
entree_son.start();
}
void draw() {
// fond gris
background(100);
move();
}
void move () {
float niveau = analyse_fft.getLevel(entree_son) * 2000;
//println (niveau);//prints sound input value
x = x + (niveau/50)*(niveau/50); // parametric speed depending on sound input
if (x > width) {
x = 0;
}
y = y + (niveau/50)*(niveau/50);
if (y > width) {
y = 0;
}
smooth();//anti aliasing
stroke(outsideCell);
strokeWeight(niveau/10); // parametric stroke depending on sound input
//noStroke();
fill(insideCell);
//noFill();
//if (mouseButton== LEFT){
ellipse(x, y, widthA+niveau/5,heightA+niveau/5); // parametric diameter depending on sound input
//ellipse(x, y, widthA,heightA);
// }
}
public void audioInputData(AudioInput theInput) {
analyse_fft.getSpectrum(entree_son);
}
//close audio input
public void stop() {
Ess.stop();
super.stop();
}