URGENT: Projection Mapping With Audio

DESPERATE ! So I need to create something like this for a uni presentation.

This is my code so far....and it wont work :( Can anybody help ?! Am willing to reimburse for your time !

gina.balich@hotmail.com

Code so far:

import deadpixel.keystone.*;
import ddf.minim.analysis.*;
import ddf.minim.*;

Keystone ks;
CornerPinSurface surface;
CornerPinSurface surface2;

Minim minim;
AudioPlayer chet;
FFT fft;

PGraphics offscreen; 


void setup() { 

  size(600, 600, P3D);

  minim = new Minim(this);
  chet = minim.loadFile("leftAlone.mp3", 2048); // This needs to be to a power of 2, spectrum size will be 1024
  fft = new FFT(chet.bufferSize(), chet.sampleRate()); // create an FFT object that has a time-domain buffer the same size as chet's sample buffer
  fft.logAverages(22, 3); // Calculate averages based on minimum octave width of 22 Hz, then split each octave into three bands
  rectMode(CORNERS);

  ks = new Keystone(this); 
  surface = ks.createCornerPinSurface(400, 300, 20); 
  surface2 = ks.createCornerPinSurface(400, 300, 20); 

  offscreen = createGraphics(400, 300, P2D);  // Offscreen buffer to draw projected surface, must match resolution of ''CornerPinSurface''

}

void draw() { 

 PVector surfaceMouse = surface.getTransformedMouse(); //Allows use of mouse events inside surface of screen

 background(0); //Redraws the background

/* Draw the scene, offscreen */

int w = int(width/fft.avgSize());

for(int i = 0; i < fft.avgSize(); i++) {
 offscreen.beginDraw();  
 offscreen.rect(i*w, height, i*w + w, height - fft.getAvg(i)*3); //Draw a rectangle for each average, multiply the value by 3 it can be better visualised
 offscreen.fill(random(255), random(0), random(0)); //Fill the rectangle with a random shade of Red ''(255)''
 offscreen.stroke(255);
 offscreen.endDraw(); 
}

 /* Renders scene, transform using corner pin surface */
 surface.render(offscreen); 
 surface2.render(offscreen); 

} 

void keyPressed() { 

 switch(key) { 
 case 'c': //Press ''c'' to enter Calibration mode, where surfaces can be modified and mapped to the shape.
   ks.toggleCalibration(); 
   break; 

 case 'l': //Press ''l'' to Load previous saved projection map
   ks.load(); 
   break; 

 case 's': //Press ''s'' when you have finished warping surfaces and are happy with the result.
   ks.save(); 
   break; 

  } 
} 
Sign In or Register to comment.