import pitaru.sonia_v2_9.*; import processing.video.*; int cellsize = 10; int cols, rows; Capture video; float level; PImage topleft, topright, btleft, btright; float x = 0; float y = 0; float xvel; float yvel; void setup() { Sonia.start(this); LiveInput.start(); level = LiveInput.getLevel(); size(320, 240); colorMode(RGB, 255, 255, 255, 100); video = new Capture(this, 320, 240, 12); //framerate(30); topleft = new PImage(video.width/2,height/2); topright = new PImage(video.width/2,height/2); btleft = new PImage(video.width/2,height/2); btright = new PImage(video.width/2,height/2); } void captureEvent(Capture camera) { camera.read(); } boolean levelreached = false; boolean loudness () { if (xvel > 50) { return true; } else { return false; } } //make pixelate function void pixelate() { if (levelreached){ for ( int i = 0; i < cols;i++) { // Begin loop for rows for ( int j = 0; j < rows;j++) { // Where are we, pixel-wise? int p = i*cellsize; int q = j*cellsize; int loc = (video.width - p - 1) + q*video.width; // Reversing x to mirror the image float r = red(video.pixels[loc]); float g = green(video.pixels[loc]); float b = blue(video.pixels[loc]); // Make a new color with an alpha component color c = color(r,g,b,75); } } } } void draw() { level = LiveInput.getLevel(); xvel= x+level*200; yvel = y+level*200; println(xvel); if(level < 0.02) { xvel = 0; yvel = 0; } //background(0); tint(0, 153,0); image(video,0,0); noTint(); topleft.copy(video,0,0,video.width/2,video.height/2,0,0,width/2,height/2); topleft.updatePixels(); tint(0,0,150); image(topleft,x-xvel/2,y-xvel/2); noTint(); image(topleft,x-xvel,y-yvel); topright.copy(video,video.width/2,0,video.width/2,video.height/2,0,0,width/2,height/2); topright.updatePixels(); image(topright,x+xvel+width/2,y-yvel); btright.copy(video,video.width/2,video.height/2,video.width/2,height,0,0,width/2,height/2); btright.updatePixels(); image(btright,x+xvel+width/2, y+yvel+height/2); btleft.copy(video,0,video.height/2,video.width/2,height,0,0,width/2,height/2); btleft.updatePixels(); image(btleft,x-xvel, y+yvel+height/2); //x += 0.1;*/ }