// 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; void setup(){ size(xSize, ySize); //lights(); //smooth(); framerate(frameRate); Sonia.start(this); // create camera (distance, lensAngle) camera = new Camera(100.0, 90.0); // create sampleReader (sampleName, bands, history, speed, degrade) sampleReader = new SampleReader("none", 512, 500, 5, 0.99); if (micInput){ LiveInput.start(sampleReader.bands); LiveInput.useEqualizer(true); LiveInput.useEnvelope(true,1.5); } // create spikeBall (numSpikes, spikeLength) spikeBall = new SpikeBall(200, 256); } void loop(){ background(153,51,0); sampleReader.exist(); camera.exist(); spikeBall.exist(); counter ++; } 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-speed][j] * degrade; } } for(int j = 0; j < bands; j ++){ spectrumHistory[0][j] = spectrum[j] * 5000.0; } } 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-speed][j] * degrade; } } for(int j = 0; j < bands; j ++){ spectrumHistory[0][j] = LiveInput.spectrum[j]; } } 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; 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(); } } //