//import libraries import pitaru.sonia_v2_9.*; import processing.video.*; //declare global variables Capture video; float level; PImage topleft, topleft2, topright, topright2, btleft ,btleft2, btright, btright2; float x = 0; float y = 0; float xvel; float yvel; void setup() { //live sound commands Sonia.start(this); LiveInput.start(); //display settings size(320, 240); colorMode(RGB, 255, 255, 255, 100); //variable for live video input video = new Capture(this, 320, 240, 12); //declare and initialize image variables topleft = new PImage(video.width/4,height/4); topleft2 = new PImage(video.width/4,height/4); topright = new PImage(video.width/2,height/2); topright2 = new PImage(video.width/2,height/2); btleft = new PImage(video.width/4,height/4); btleft2 = new PImage(video.width/4,height/4); btright = new PImage(video.width/4,height/4); btright2 = new PImage(video.width/4,height/4); } //function to capture live video void captureEvent(Capture camera) { camera.read(); } void draw() { //initialize sound level variable level = LiveInput.getLevel(); //initialize variables to move video pieces xvel= x+level*300; yvel = y+level*300; //println(xvel); //adjust sensitivity of response if(level < 0.02) { xvel = 0; yvel = 0; } //set background layer of video image(video,0,0); filter(INVERT); //copy sections of video image into Pimage variables topleft.copy(video,video.width/2, video.height/2,video.width/4,video.height/4,0,0,width/4,height/4); topleft.updatePixels(); image(topleft,x,y+yvel); topleft2.copy(video,video.width/4,video.height/4,video.width/4,video.height/4,0,0,width/4,height/4); topleft2.updatePixels(); image(topleft2,x+width/4,y-yvel+height/4); topright.copy(video,240,video.height/4,video.width/4,video.height/4,0,0,width/4,height/4); topright.updatePixels(); image(topright,x+xvel+video.width/2,y-yvel); topright2.copy(video,video.width/4,video.height/2,video.width/4,video.height/4,0,0,width/4,height/4); topright2.updatePixels(); image(topright2,x+xvel+240,y-yvel+video.height/4); btright.copy(video,240,180,video.width/4,height/4,0,0,width/4,height/4); btright.updatePixels(); image(btright,x+240, y-xvel+180); btright2.copy(video,video.width/2,video.height/2,video.width/4,height/4,0,0,width/4,height/4); btright2.updatePixels(); image(btright2,x-xvel/2+video.width/2, y+video.height/2); btleft.copy(video,0,video.height/4,video.width/4,video.height/4,0,0,width/4,height/4); btleft.updatePixels(); image(btleft,x-xvel+width/4, y-yvel+180); btleft2.copy(video,240,180,video.width/4,video.height/4,0,0,width/4,height/4); btleft2.updatePixels(); image(btleft2,x+xvel, y+yvel+height/2); }