xxxxxxxxxx
import processing.video.*;
import themidibus.*;
MidiBus myBus;
Capture cam;
int center_x;
int center_y;
int diam_x;
int diam_y;
void setup() {
size(320, 180);
MidiBus.list();
String[] cameras = Capture.list();
if(cameras.length == 0) {
println("No cameras available");
exit();
} else{
for(int i = 0; i< cameras.length; i++){
//println(cameras[i]);
}
}
myBus = new MidiBus(this, "Oxygen 25", "Oxygen 25");
cam = new Capture(this, 320, 180, 15);
cam.start();
center_x = 0;
center_y = 0;
diam_x = 64;
diam_y = 64;
frameRate(15);
noFill();
}
void draw() {
//background(255,1);
if(cam.available()){
cam.read();
}
cam.loadPixels();
for(int x = 0; x < 320; x++) {
for(int y = 0; y < 180; y++) {
if(random(-100,1) > 0){
color pix = cam.get(x, y);
stroke(pix,100);
ellipse(x+center_x, y+center_y, diam_x, diam_y);
}
}
}
}
void controllerChange(int channel, int number, int value) {
println("Channel: " + channel);
println("Number: " + number);
println("Value: " + value);
if(number==71){
center_x = (int) map(value, 0, 127, -width/2, width/2);
}
if(number==72){
center_y = (int) map(value, 0, 127, -height/2, height/2);
}
if(number==22){
diam_x = (int) map(value, 0, 127, 1, width);
diam_y = (int) map(value, 0, 127, 1, height);
}
}