I had a problem with this too... here's a sound-reactive program I wrote... it was having problems with tearing. I found something in a forum thread, somewhere.... that allowed me to turn on vsync which fixed the problem. I've posted the whole program but you can see the vsync bit at the start and in setup. I hope this helps.
[EDIT-If you want to see this program working you need a working microphone which is successfully detected by Minim. Try turning off the openGL stuff to see the horrible tearing]
Code:import ddf.minim.analysis.*;
import ddf.minim.*;
import processing.opengl.*;
import javax.media.opengl.GL;
Minim minim;
AudioInput in;
FFT fft;
//PrintWriter output;
float[] bands;
float amplitude=0;
float h, s, b; //hue saturation, brightness
PGraphicsOpenGL pgl; //need to use this to stop screen tearing
GL gl;
void setup()
{
size(640, 480, OPENGL);
pgl = (PGraphicsOpenGL) g; //processing graphics object
gl = pgl.beginGL(); //begin opengl
gl.setSwapInterval(1); //set vertical sync on
pgl.endGL(); //end opengl
background(0);
frameRate(30);
//output= createWriter("sounddata.txt");
bands = new float[10];
minim = new Minim(this);
in = minim.getLineIn(Minim.STEREO, 512);
fft= new FFT(in.bufferSize(), in.sampleRate());
fft.logAverages(22, 1);
colorMode(HSB, 255, 255, 255);
}
void draw()
{
amplitude=0;
fft.forward(in.mix);
for(int i=0; i<fft.avgSize(); i++)
{
bands[i]=fft.getAvg(i);
}
s = (bands[0] + bands[1] + bands[2] + bands[3])/4;
b = (bands[4] + bands[5] + bands[6])/3;
h= (bands[7] + bands[8] + bands[9])/3;
for(int i=0; i<10; i++)
{
amplitude+= bands[i];
}
s= map(s, 0.88, 1, 0, 255);
b = map(b, 0.026, 1, 0, 255);
h= map(h, 0.011, 0.5, 0, 255);
color c = color(h, s, b);
loadPixels();
for (int i=0; i< pixels.length; i++)
{
pixels[i]=c;
}
updatePixels();
}