import krister.Ess.*; int buffer = 1024; int numaverages = 128; int steps; float minlimit = 0.005; float maxlimit = 0.05; float damp = 0.05; float vol; float[] pastvolume = new float[256]; float tolerance = 0.0; float limitdiff = maxlimit - minlimit; FFT myFFT; AudioInput input; void setup(){ size(256,256); Ess.start(this); input = new AudioInput(buffer); myFFT = new FFT(buffer*2); myFFT.equalizer(true); myFFT.limits(minlimit, maxlimit); myFFT.damp(damp); myFFT.averages(numaverages); steps = buffer/numaverages; input.start(); colorMode(1, 1.0, 1.0, 1.0); } void draw(){ background(0); if(mouseY > 0 && mouseY < height){ tolerance = (float)mouseY/height; } vol = highest(myFFT); pastvolume = push(pastvolume, vol); pastvolume = pop(pastvolume); for(int y=0; y tolerance){ stroke(pastvolume[y]); line(0,y,width,y); } } } void audioInputData(AudioInput theInput) { myFFT.getSpectrum(input); } float average(FFT fft){ float all = 0; float ampavg; for(int i=0; i highest){ highest = fft.averages[i]; } } return highest; } float[] push(float[] a, float element){ float[] b = new float[a.length+1]; b[0] = element; System.arraycopy(a,0,b,1,a.length); return b; } float[] pop(float[] a){ float[] b = new float[a.length-1]; System.arraycopy(a,0,b,0,a.length-1); return b; }