::: Cells now bounce on the frame. The speed increases and inside fill changes its color depending on sound input... I've created a class to build the cells. Suggestions are very welcome / Dont forget to download the Ess (see below) library if you want to use this code. Enjoy ::: François




import krister.Ess.*;
AudioInput entree_son;
FFT analyse_fft;

int buffer = 512;
float normalisation;

//import processing.video.*;
//MovieMaker mm; // Declare MovieMaker object

//..................................................................................................................
Cell myCell1;
Cell myCell2;
Cell myCell3;
Cell myCell4;
Cell myCell5;
Cell myCell6;
Cell myCell7;
Cell myCell8;
Cell myCell9;
Cell myCell10;

float niveau;
float size = 100; // diameter
float xpos, ypos; // starting position of the shape / dynamic coordinates definition
int xdirection = 1; // Left or Right
int ydirection = 1; // Top to Bottom

//..................................................................................................................
void setup() {

size(860,600);
frameRate(60);
smooth();//anti aliasing

//mm = new MovieMaker(this, 860, 600, "6ellipses.mov",30, MovieMaker.H263, MovieMaker.HIGH);

myCell1 = new Cell (color (niveau,niveau,niveau),xpos,ypos,0.8,0.2,xdirection,ydirection);
myCell2 = new Cell (color (niveau,niveau,niveau),xpos,ypos,0.4,0.1,xdirection,ydirection);
myCell3 = new Cell (color (niveau,niveau,niveau),xpos,ypos,1,0.3,xdirection,ydirection);
myCell4 = new Cell (color (niveau,niveau,niveau),xpos,ypos,0.7,0.9,xdirection,ydirection);
myCell5 = new Cell (color (niveau,niveau,niveau),xpos,ypos,0.1,0.1,xdirection,ydirection);
myCell6 = new Cell (color (niveau,niveau,niveau),xpos,ypos,0.2,0.05,xdirection,ydirection);
myCell7 = new Cell (color (niveau,niveau,niveau),xpos,ypos,0.4,0.9,xdirection,ydirection);
myCell8 = new Cell (color (niveau,niveau,niveau),xpos,ypos,0.11,0.3,xdirection,ydirection);
myCell9 = new Cell (color (niveau,niveau,niveau),xpos,ypos,0.2,0.5,xdirection,ydirection);
myCell10 = new Cell (color (niveau,niveau,niveau),xpos,ypos,0.6,0.5,xdirection,ydirection);


Ess.start(this);
entree_son=new AudioInput(buffer);
analyse_fft=new FFT(buffer * 100);
analyse_fft.equalizer(true);
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;
entree_son.start();

}

//..................................................................................................................
void draw() {

background(10);
myCell1.move();
myCell2.move();
myCell3.move();
myCell4.move();
myCell5.move();
myCell6.move();
myCell7.move();
myCell8.move();
myCell9.move();
myCell10.move();

//mm.addFrame(); // Add window's pixels to movie


}

//..................................................................................................................
class Cell {
color c;
float xpos;
float ypos;
float xspeed;
float yspeed;
float xdirection;
float ydirection;

Cell(color tempC, float tempXpos, float tempYpos, float tempXspeed, float tempYspeed, float tempXdirect, float tempYdirect) {
c = tempC;

xpos = width/2;
ypos = height/2;
xspeed = tempXspeed;
yspeed = tempYspeed;
xdirection = tempXdirect;
ydirection = tempYdirect;
}

//..................................................................................................................
void move() {

float niveau = analyse_fft.getLevel(entree_son) * 2000;

c = color(48,niveau,131,200);

xspeed = xspeed + ((niveau/500)*(niveau/500));
if(xspeed >= 4) { // in case they are too fast, slow them down
xspeed = yspeed/5;
}

yspeed = yspeed + ((niveau/500)*(niveau/500));
if(yspeed >= 4) {
yspeed = yspeed/5;
}

stroke(64,193,255);
strokeWeight(niveau/10); // parametric stroke depending on sound input
//noStroke();
fill(c);
//noFill();
ellipseMode(CENTER);
ellipse(xpos,ypos,size+niveau/10,size+niveau/10);

xpos = xpos + (xspeed * xdirection);
if (xpos > width|| xpos < ypos =" ypos"> height || ypos < key ="=">