We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there, I'm trying to do a sketch where "notes" (coloured balls) are created sampling an audio source. They should disappear after some time, and they do, but they appear and disappear a few times very quickly before disappearing definately, it's not smooth. I suspect there's something wrong with where I placed the remove(). This is my draw code and a separate method for creating the "notes", so that they appear in their correct frequency band:
ArrayList noteCollection = new ArrayList();
void draw() {
colorMode(RGB, 255);
fft.forward(in.mix);
filter.run(fft, runMode, bands);
if ((runMode == 5)) {
bandFiltering();
create();
pushMatrix();
translate(width/2, height/2);
background(0);
for (int i = 0; i < noteCollection.size (); i++) {
Note note = (Note) noteCollection.get(i);
note.run();
if (note.timer == 0) {
//println("Note removed");
noteCollection.remove(note);
}
}
popMatrix();
}
}
void create() {
pushMatrix();
translate(width/2, height/2);
for (int i = 0; i < 3; i++) {
if (dominantFreq[1][i] > 2 ) {
//Create a new note
int ellipseXMin = -width/2 + i * (width/3);
int ellipseXMax = -width/2 + (i+1) * (width/3);
int ellipseX = int(random(ellipseXMin, ellipseXMax));
Vec3D origin = new Vec3D(ellipseX, 0, 0);
//println("Note frequency " + dominantFreq[0][i] + " and note amplitude " + dominantFreq[1][i]);
//println("Note origin " + origin);
Note note = new Note(origin, dominantFreq[0][i], dominantFreq[1][i], 10000);
noteCollection.add(note);
}
}
popMatrix();
}
Any suggestions? I can't seem to figure this out by myself, anything will be appreciated.
Answers
http://forum.processing.org/two/discussions/tagged/backwards
I've also experienced some serious frame rate issues, do you think this is also the cause? I can't fix it right now because I'm at work but I'm curious!
line 33 , 34 and 53 why...?
After a lot of pain I realized that using translate in draw screwed up a drop down list that I was using from the library ControlP5. So instead I push and pop the matrix as necessary if it makes things easier for me :) Would this cause problems?
also background at start of draw()?
should be better
causing no problems, no
Well I put it there because I have other run modes that don't refresh the background, but yes I think I should change that and move it up a couple lines maybe.
after line 10