We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › How to apply filter to certain elements
Page Index Toggle Pages: 1
How to apply filter to certain elements? (Read 494 times)
How to apply filter to certain elements?
Mar 7th, 2008, 5:46pm
 
Hi,

I'm new on processing and I'm starting to create a simple sketch using ESS to make a cube react with the sound (see the code below).
Now the question is, how can I apply that Blur filter to just the drawCube() function instead of the whole sketch?
Because the rect's are being affected with the BLUR too.

Quote:


import krister.Ess.*;
import processing.opengl.*;
import javax.media.opengl.*;
// start
FFT fft;
AudioInput in;
int bufferSize;
float [] zoneFill;
int beat;

void setup(){
 size(532, 230, OPENGL);  
 Ess.start(this);
 bufferSize = 1024;
 in = new AudioInput(bufferSize);
 fft = new FFT(bufferSize);
 fft.equalizer(true);
 in.start();
 // set up our FFT normalization/dampening
 float minLimit=.005;
 float maxLimit=.05;
 float myDamp=.1f;
 int numAverages=32;
 fft.limits(minLimit,maxLimit);
 fft.damp(myDamp);
 fft.averages(numAverages);
 zoneFill = new float[]{
   255.0, 255.0, 255.0    };
 noStroke();
}

// Maximum fft 1.0
// Minimum fft 0.0
// After init to Ess FFT demo that is
void draw(){
 background(242, 240, 174);
 noStroke();
 fill(color(131,104,81), 50);
 for(int i=0; i<bufferSize/2; i++) {
   rect(10+i,10,1,fft.spectrum[i]*200);
 }
 stroke(0);

//  pushMatrix();
 drawCube();
//  popMatrix();  
}

public void drawCube() {
 print((10*fft.getLevel(in)) + "\n");
 translate(250, 100, 3);
 rotateZ(radians(frameCount)+(1*fft.getLevel(in)));
 rotateX(radians(frameCount)+(1*fft.getLevel(in)));
 fill(color(100, 100, 100));
 box(35+(50*fft.getLevel(in)));
 // filter(BLUR, 2);
}

public void audioInputData(AudioInput theInput) {
 fft.getSpectrum(in);
}
public void stop() {
 Ess.stop();
 super.stop();
}


Re: How to apply filter to certain elements?
Reply #1 - Mar 21st, 2008, 12:04am
 
I'd like to know the answer to this as well. I'm guessing it has something to do with the filter looking for an image and finding none.
Page Index Toggle Pages: 1