// applet size variables int xSize = 300; int ySize = 300; int xMid = xSize/2; int yMid = ySize/2; int frameRate = 30; int counter = 0; Camera camera; SampleReader sampleReader; SpikeBall spikeBall; boolean micInput = true; //float[] clearZ; BImage myField; void setup(){ size(xSize, ySize); //lights(); //smooth(); framerate(frameRate); background(51,0,0); Sonia.start(this); //init_blur(2); // create camera (distance, lensAngle) camera = new Camera(75.0, 60.0); // create sampleReader (sampleName, bands, history, speed, degrade) sampleReader = new SampleReader("none", 512, 500, 10, .98); if (micInput){ LiveInput.start(sampleReader.bands); LiveInput.useEqualizer(true); LiveInput.useEnvelope(true,1.5); } // create spikeBall (numSpikes, spikeLength) spikeBall = new SpikeBall(128, 128); myField = loadImage("field.gif"); brightToAlpha(myField); //clearZ=new float[width*height]; //System.arraycopy(g.zbuffer,0,clearZ,0,clearZ.length); } void loop(){ background(35); //fill(51,0,0,50); //rect(0,0,xSize,ySize); //System.arraycopy(clearZ,0,g.zbuffer,0,clearZ.length); //fastblur(); sampleReader.exist(); camera.exist(); spikeBall.exist(); counter ++; //saveFrame("screenGrabs/test-####.tif"); delay(10); } class SpikeBall{ int numSpikes; int spikeLength; float fillColor; float[] positionRandomizer; SpikeBall(int sentNumSpikes, int sentSpikeLength){ numSpikes = sentNumSpikes; spikeLength = sentSpikeLength; positionRandomizer = new float[numSpikes]; for (int i=0; i= speed; i -= speed){ for(int j = 0; j < bands; j ++){ spectrumHistory[i][j] -= (spectrumHistory[i][j] - (spectrumHistory[i-speed][j] * degrade)) * .85; } } for(int j = 0; j < bands; j ++){ spectrumHistory[0][j] -= (spectrumHistory[0][j] - (spectrum[j]*15000.0)) * .9; } } void processSignal(){ for(int i = history - speed; i >= speed; i -= speed){ for(int j = 0; j < bands; j ++){ signalHistory[i][j] -= (signalHistory[i][j] - (signalHistory[i-speed][j] * degrade)) * .7; } } for(int j = 0; j < bands; j ++){ signalHistory[0][j] -= (signalHistory[0][j] - signal[j]) * .5; } } void processMicSpectrum(){ LiveInput.getSpectrum(false); for(int i = history - speed; i >= speed; i -= speed){ for(int j = 0; j < bands; j ++){ spectrumHistory[i][j] -= (spectrumHistory[i][j] - (spectrumHistory[i-speed][j] * degrade)) * .85; } } for(int j = 0; j < bands; j ++){ spectrumHistory[0][j] -= (spectrumHistory[0][j] - LiveInput.spectrum[j]) * .7; } } void processMicSignal(){ LiveInput.getSpectrum(false); for(int i = history - speed; i >= speed; i -= speed){ for(int j = 0; j < bands; j ++){ signalHistory[i][j] -= (signalHistory[i][j] - (signalHistory[i-speed][j] * degrade)) * .85; } } for(int j = 0; j < bands; j ++){ signalHistory[0][j] -= (signalHistory[0][j] - (constrain(LiveInput.signal[j]*.5,0,500))) * .9; } } void setCounter(){ timeCounter += (1.0f/float(frameRate)); } } class Camera{ // camera variables float xPos, yPos; float rotationVar; float elevation; float azimuth; float twist; float distance; float lensAngle; boolean autoRotate = true; Camera (float sentDistance, float sentLensAngle){ distance = sentDistance; lensAngle = sentLensAngle; } void exist(){ findRotation(); setCamera(); } void findRotation(){ if (autoRotate){ xPos = cos(counter/100.0) * 65.0; yPos = sin(counter/135.0) * 100.0; } else { xPos -= (xPos - (xMid - mouseX)) * .2; yPos -= (yPos - (yMid - mouseY)) * .2; } } void setCamera(){ beginCamera(); perspective(lensAngle, (float)xSize / (float)ySize, 1.0f, 500); translate(0, 0, -distance); twist = radians(xPos); elevation = radians(yPos); rotateY(-twist); rotateX(elevation); rotateZ(-azimuth); endCamera(); } } int radius; int w, h, wm, hm, wh, div; int R[]; int G[]; int B[]; int rsum,gsum,bsum,x,y,i,p,p1,p2,yp,yi,yw; int vmin[]; int vmax[]; int dv[]; void init_blur(int rad) { radius = rad; w = width; h = height; wm = w-1; hm = h-1; wh = w*h; div = radius+radius+1; R = new int[wh]; G = new int[wh]; B = new int[wh]; vmin = new int[max(w,h)]; vmax = new int[max(w,h)]; dv = new int[256*div]; for (i=0;i<256*div;i++){ dv[i]=(i/div); } } void fastblur(){ yw=yi=0; for (y=0;y>16; gsum+=(p & 0x00ff00)>>8; bsum+= p & 0x0000ff; } for (x=0;x>16; gsum+=((p1 & 0x00ff00)-(p2 & 0x00ff00))>>8; bsum+= (p1 & 0x0000ff)-(p2 & 0x0000ff); yi++; } yw+=w; } for (x=0;x