// applet size variables int xSize = 400; int ySize = 300; int xMid = xSize/2; int yMid = ySize/2; // camera variables float xMouse, yMouse; float rotationVar; float elevation, azimuth, twist; float cd = 300; // camera distance float cdDest = 300.0; // destination camera distance float cp = 85.0; // camera perspective float cpDest = 85.0; // destination camera perspective int counter = 0; int ribbonLength = 200; int ribbonSpeed = 5; int ribbonWidth = 4; float segmentWidth; int ribbonRibs = 128; float degrade = .99; float signalDegrade = .96; float fillColor; // SONIA ADD ONS int fBands = 128; float spectrumArray[][]; float[] randomVar; BImage myField; BImage myGlow; boolean autoRotate = true; color bgColor; float bgRed, bgGreen = 0.0; float bgBlue = 25.0; float bgr,bgg,bgb; float mySize; int audioType = 3; int audioSymmetry = 2; void setup(){ size(xSize, ySize); //lights(); //smooth(); background(0); colorMode(RGB,255); framerate(30); ellipseMode(CENTER_RADIUS); elevation = radians(15.0f); azimuth = radians(0.0f); cdDest = 450; Sonia.start(this); LiveInput.start(fBands); LiveInput.useEqualizer(true); LiveInput.useEnvelope(true,1.5); spectrumArray = new float[ribbonLength*2+1][fBands]; bgColor = color(0,0,25); myField = loadImage("field.gif"); myGlow = loadImage("field2.gif"); brightToAlpha(myField); brightToAlpha(myGlow); randomVar = new float[ribbonRibs]; for (int i = 0; i 1){ ribbonWidth --; } else if (key == 'a' || key == 'A'){ if (autoRotate){ autoRotate = false; } else { autoRotate = true; } } else if (key == 's' || key == 'S'){ audioSymmetry = 1; } else if (key == 'd' || key == 'D'){ audioSymmetry = 2; } } void processAudioSingle(){ LiveInput.getSpectrum(false); for(int i = ribbonLength*2 - ribbonSpeed; i >= ribbonSpeed; i -= ribbonSpeed){ for(int j = 0; j < fBands; j ++){ spectrumArray[i+ribbonSpeed][j] -= (spectrumArray[i+ribbonSpeed][j] - (spectrumArray[i][j] * degrade)) * signalDegrade; } } for(int j = 0; j < fBands; j ++){ spectrumArray[ribbonSpeed][j] = LiveInput.spectrum[j]/3.0; } } void processAudioSymmetry(){ LiveInput.getSpectrum(false); for(int i = ribbonSpeed; i <= ribbonLength; i += ribbonSpeed){ for(int j = 0; j < fBands; j ++){ spectrumArray[i-ribbonSpeed][j] -= (spectrumArray[i-ribbonSpeed][j] - (spectrumArray[i][j] * degrade)) * signalDegrade; } } for(int i = ribbonLength*2 - ribbonSpeed; i >= ribbonLength; i -= ribbonSpeed){ for(int j = 0; j < fBands; j ++){ spectrumArray[i+ribbonSpeed][j] -= (spectrumArray[i+ribbonSpeed][j] - (spectrumArray[i][j] * degrade)) * signalDegrade; } } for(int j = 0; j < fBands; j ++){ spectrumArray[ribbonLength][j] = LiveInput.spectrum[j]; } } void doCamera(){ if (autoRotate){ xMouse = cos(counter/100.0) * 65.0; yMouse = sin(counter/135.0) * 100.0; //azimuth = sin(counter/50.0) * 7.0; } else { xMouse -= (xMouse - (xMid - mouseX)) * .2f; yMouse -= (yMouse - (yMid - mouseY)) * .2f; } beginCamera(); cp -= (cp - cpDest) * .2; cd -= (cd - cdDest) * .2; perspective(cp, (float)xSize / (float)ySize, 1.0f, 500); translate(0, 0, -cd); twist = radians(xMouse); elevation = radians(yMouse); rotateY(-twist); rotateX(elevation); rotateZ(-azimuth); endCamera(); } void fuzzySphere(){ for (int j=0; j