Hi I'm a real novice at Processing still, & am trying to learn to use libraries, and have come up against a problem saving values created using one of the minim examples to an arraylist of objects.
The sketch below is a basic equiliser built from an example, where I have tried to create an arraylist to hold 'stills' from the equiliser bars as objects in an arraylist, then draw the whole list to the screen (so the 'past sound levels' are drawn extending off into the distance).
- Basically I'm trying to combine an eq graph with this processing example:
http://processing.org/learning/topics/arraylistclass.htmlMy new objects seem to create & display, but they are all updating to show the current equiliser values instead of the ones set when they were created - am I just sourcing the wrong set of values to draw from in my object display() function Thank you.
Code:import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
ArrayList rowsArrayList = new ArrayList();
float[] currentRowArray = new float[257];
FFT fftLog1;
Minim minim;
AudioInput groove1;
void setup() {
size(600,400, P3D);
frameRate(5);
minim = new Minim(this);
groove1 = minim.getLineIn(Minim.MONO, 512);
fftLog1 = new FFT(groove1.bufferSize(),groove1.sampleRate());
strokeWeight(1);
}
void draw() {
background(0);
fftLog1.forward(groove1.mix); //combine stereo into mono sound.
for(int b=0; b<rowsArrayList.size(); b++){//loop through all arraylist..
BarRowObject currentRow = (BarRowObject) rowsArrayList.get(b);
translate(0, 0, b*-10);
currentRow.display();
}
if(rowsArrayList.size() >10){//makes sure there arraylist is a limited length..
rowsArrayList.remove(0);
}
}//end of draw.
void keyPressed(){
for(int i = 0; i < fftLog1.specSize(); i++) {
currentRowArray[i] = (fftLog1.getBand(i)*100);
}
rowsArrayList.add(new BarRowObject(currentRowArray));
}
class BarRowObject {
float[] barValues = new float[256];
public BarRowObject ( float[] tempBarValues ){;
barValues = tempBarValues;
}
void display(){
stroke(255);
for(int i = 0; i < fftLog1.specSize(); i++) {
pushMatrix();
translate(i*10, (height*0.75)-(((fftLog1.getBand(i)*100))/2), 0);
noFill();
box(10, (fftLog1.getBand(i)*100), 10);
popMatrix();
}
}
}