// Oscar G. Torres | www.blubee.com // with help from: //* Image Explode //* by Daniel Shiffman. // SOUND Input FFT // original code by Marius Watz // modified by Krister Olsson Art starBaby = new Art(); ////// Art Class Vars float angle = 0; float px = 0, py = 0; float amplitude = 10; float frequency = 0.1; float fillGap = 2; color c; int sX, sY; int i; float zA; //int ct=1; //////////////// PImage img; // The source image PImage swirl; int cellsize =8; // Dimensions of each cell in the grid int COLS, ROWS; // Number of columns and rows in our system float ct=0; float colorA; float colorB; float colorC; float colorD; ///++++++++++++++++++++++++++++++++++++++++++++++++++++++++ import krister.Ess.*; int bufferSize; int steps; float limitDiff; int numAverages=32; float myDamp=.1f; float maxLimit,minLimit; FFT myFFT; AudioInput myInput; ///++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void setup(){ size(900, 600, P3D); background(0); img = loadImage("wasp.jpg"); // Load the image swirl= loadImage("swirl2.png"); COLS = img.width/cellsize; // Calculate # of columns ROWS = img.height/cellsize; // Calculate # of rows colorMode(RGB,255,255,255,100); // Setting the colormode ///++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // start up Ess Ess.start(this); // set up our AudioInput bufferSize=512; myInput=new AudioInput(bufferSize); // set up our FFT myFFT=new FFT(bufferSize*2); myFFT.equalizer(true); // set up our FFT normalization/dampening minLimit=.0001; maxLimit=.9; myFFT.limits(minLimit,maxLimit); myFFT.damp(myDamp); myFFT.averages(numAverages); // get the number of bins per average steps=bufferSize/numAverages; // get the distance of travel between minimum and maximum limits limitDiff=maxLimit-minLimit; frameRate(30); myInput.start(); ///++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } void draw(){ // background(0); i++; if ( i<80){ sX=round(random(width)); sY=round(random(height)); pushMatrix(); fill(30,random(100)); translate(sX,sY); scale(random(.5)); starBaby.star(1); popMatrix(); } if (mousePressed == false) { //ct=0; } ///++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // draw the waveform stroke(255,100); int interp=(int)max(0,(((millis()-myInput.bufferStartTime)/(float)myInput.duration)*myInput.size)); for (int i=0;i1) myDamp=1; else if(myDamp<0) myDamp=0; myFFT.damp(myDamp); background(colorD, colorA, colorB); // Begin loop for columns for ( int i = 0; i < COLS;i++) { // Begin loop for rows for ( int j = 0; j < ROWS;j++) { float monk= cellsize+ct; int x = i*cellsize +cellsize/2; // x position int y = j*cellsize +cellsize/2; // y position int loc = x + y*img.width; // Pixel array location color c = img.pixels[loc]; // Grab the color float rr = round( red(img.pixels[loc]) ); float gg = round( green(img.pixels[loc])); float bb = round( blue(img.pixels[loc])); if (rr< 30){ rr=0; } if (rr> 85){ // rr=127; } if (rr > 170){ // rr=255; } // gg = round( green(img.pixels[loc])); if (gg< 30){ gg=0; } if (rr> 85){ // gg=127; } if (gg > 170){ // gg=255; } // bb = round( blue(img.pixels[loc])); if (bb< 30){ bb=0; } if (bb> 85){ // bb=127; } if (bb > 170){ // bb=255; } // float tt = rr+gg+bb; // Calculate a z position as a function of mouseX and pixel brightness float z = (ct / (float) img.width) * brightness(img.pixels[loc]) - 100.0f; // (mouseX / (float) width) * brightness(img.pixels[loc]) - 100.0f; // Translate to the location, set fill and stroke, and draw the rect pushMatrix(); float xA= x-70; // coffeCupY= bannanaBoat *sin(angleA*yummyRum)+bannanaBoat; float yA= y-70; zA= ( (myInput.buffer2[round(brightness(img.pixels[loc]))]*2000) / (float) img.width) * brightness(img.pixels[loc]) + 10.0f; /// myInput.buffer2[round(brightness(img.pixels[loc]))]*300.0 ; ///myFFT.spectrum[round(brightness(img.pixels[loc]))]*400 ; // ; int cell= cellsize+2; noStroke(); translate(xA*2,yA*2,z); // fill(rr, gg,bb, 100-zA); tint(rr, gg,bb); rotate(PI/zA); image(swirl,0,0); // image(swirl,0,0); ////// rectMode(CENTER); ///// rect(0,0,cellsize,cellsize); //fill(255-rr, 100-gg, 255-bb); //println(myInput.buffer2[round(brightness(img.pixels[loc]))]*20000); //println( brightness(img.pixels[loc])); //rect(100,50,cellsize/2,cellsize/2); popMatrix(); } } } public void audioInputData(AudioInput theInput) { myFFT.getSpectrum(myInput); } ///++++++++++++++++++++++++++++++++++++++++++++++++++++++++ class Art{ float bannanaMan=1; float fatCheeseburger=0; float alphaMonkey=0; float trans=0; Art(){ float angle = 0; float px = 0, py = 0; float amplitude = 10; float frequency = 0; float fillGap = .002; color c; } void circle(){ fill(bannanaMan,0,0,alphaMonkey); ellipse(random(width),(fatCheeseburger+100),fatCheeseburger,fatCheeseburger); stroke(100,200,4); fatCheeseburger= random(600); bannanaMan= random(255); alphaMonkey= random(200); } void star(float fatCheeseburger){ // float tempX= (abs(random(width))); beginShape(); vertex(fatCheeseburger-27, fatCheeseburger-1); vertex(fatCheeseburger+0, fatCheeseburger-1); vertex(fatCheeseburger+9, fatCheeseburger-27); vertex(fatCheeseburger+18, fatCheeseburger-1); vertex(fatCheeseburger+43, fatCheeseburger-1); vertex(fatCheeseburger+23, fatCheeseburger+16); vertex(fatCheeseburger+32, fatCheeseburger+43); vertex(fatCheeseburger+9, fatCheeseburger+27); vertex(fatCheeseburger-14, fatCheeseburger+43); vertex(fatCheeseburger-4, fatCheeseburger+15); vertex(fatCheeseburger-27, fatCheeseburger-1); endShape(); } void gradient(int trans){ for (int i =- 75; i < height+75; i++){ // reset angle to 0, so waves stack properly angle = 0; // increasing frequency causes more gaps frequency+=.006; for (float j=0; j