::: Cells are now going faster and increase their connection radius with the sound intensity. They are mostly sensitive to low frequencies. A good minimal track with bass and breaks will clearly reveal their flocking rules. ::: enjoy
import krister.Ess.*;
AudioInput sound_input;
FFT analyse_fft;
int buffer = 1024;
//int buffer = 512;
float normalisation;
//import processing.video.*;
//MovieMaker mm; // Declare MovieMaker object
int fisheZ = 10; // amount of fisheZ
int frameX = 500; // frame definition
int frameY = 500; // frame size y-direction
float inc = 0.0035; // move increasement every loop // speed
float pX, pY, nX, nY;
float[] ptsX = new float[fisheZ]; // declare + create array X
float[] ptsY = new float[fisheZ]; // declare + create array Y
float[] posX = new float[fisheZ]; // declare + create array X
float[] posY = new float[fisheZ]; // declare + create array Y
void setup() {
size(frameX, frameY);
//frameRate(30);
//mm = new MovieMaker(this,frameX, frameY, "fish_Network",30, MovieMaker.H263, MovieMaker.HIGH);
Ess.start(this);//starts ESS
sound_input=new AudioInput(buffer);//get access to audio input
// start audio analyzer
analyse_fft=new FFT(buffer * 100);
analyse_fft.equalizer(true);
float min_limit=.005;//normalizing values
float max_limit=.05;
analyse_fft.limits(min_limit,max_limit);
analyse_fft.damp(.1f);
analyse_fft.averages(32);
normalisation = max_limit - min_limit;
sound_input.start();//starts your engines
smooth();
for (int i = 0; i <>
ptsX[i] = random(0, frameX); // write start pts to arrayX
ptsY[i] = random(0, frameY); // write start pts to arrayY
posX[i] = ptsX[i];
posY[i] = ptsY[i];
}
}
void draw() {
float Level = analyse_fft.getLevel(sound_input) * 3000; // sound value
//mm.addFrame(); // Add window's pixels to movie
background(20);
color cellfill = color(38,Level,131,200+Level/200);
color cellstroke = color(64,193,255,100);
fill(cellfill);
stroke(64,193,255,100);
// Update the fisheZ positions
for (int i = 0; i <>
posX[i] = noise(ptsX[i]) * frameX; // Update the screen position
posY[i] = noise(ptsY[i]) * frameY;
ptsX[i] = ptsX[i] + (inc*Level/80); // Update position in Perlin noise space
ptsY[i] = ptsY[i] + (inc*Level/80);
}
// Draw the connecting lines
strokeWeight(3);
for (int i = 0; i <>
for (int j = i; j <>
if (dist(posX[j], posY[j], posX[i], posY[i]) <>
line(posX[j], posY[j], posX[i], posY[i]);
}
}
}
// draw the fisheZ last so they are not masked by lines
strokeWeight(0.5+Level/20);
for (int i = 0; i <>
ellipse(posX[i], posY[i], 5+Level/10,3+Level/10); // insert ellipse/pts
}
}
//void keyPressed() {
// if (key == ' ') {
// mm.finish(); // Finish the movie if space bar is pressed!
// }
//}
///////////////////////////////////////////////////////////////////////////////////
//sound input stop
public void audioInputData(AudioInput theInput) {
analyse_fft.getSpectrum(sound_input);
}
//close audio input
public void stop() {
Ess.stop();
super.stop();
}