visual music redonee

import ddf.minim.*;
import ddf.minim.analysis.*;
import gab.opencv.*;
import java.awt.*;
import processing.video.*;
Capture video;
OpenCV opencv;
Minim minim;
AudioPlayer song;
FFT fft;

int counter;
int interval = 20000;
color RanColor;
boolean goCrazy;
int r = 0;
int g = 255;
int b = 0;

void setup() {

size(720,480);
video = new Capture (this, 640/2, 480/2);
opencv = new OpenCV(this, 640/2, 480/2);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);

video.start();
minim = new Minim(this);
song = minim.loadFile(“Bottom of the Bottom.mp3”, 512);
song.play();
fft = new FFT(song.bufferSize(), song.sampleRate());
RanColor = color(200,6,128);
}
void draw() {
counter ++;

stroke (RanColor);
if( counter > 20) {

RanColor=color(random(255), random(255), random(255));
}

scale(2);
opencv.loadImage(video);
image(video,0,0);
noFill();
stroke(RanColor);
strokeWeight(4);
Rectangle[] faces = opencv.detect();
println(faces.length);
for (int i = 0; i <faces.length && i < song.left.size(); i++) {
println(faces[i].x + “,” + faces[i].y);
rect(faces[i].x +song.left.size() ,faces[i].y, faces[i].width, faces[i].height);
}
for(int i = 0; i < song.left.size() – 1 &&i<faces.length; i++) {
rect(faces[i].y, faces[i].x + song.left.get(i)*50, i+1, 50 + song.left.get(i+1)*50);
rect(faces[i].x, 50 + song.left.get(i)*50, i+1, 80 + song.left.get(i+1)*50);
for(int d = 0; d < song.left.size() – 1; d++) {
rect(80, faces[i].y + song.left.get(i)*50, i+1, 50 + song.left.get(i+1)*50);
rect(100, faces[i].y + song.left.get(i)*50, i+1, 50 + song.left.get(i+1)*50);
rect(200, faces[i].y + song.left.get(i)*50, i+1, 50 + song.left.get(i+1)*50);

} }
}

void captureEvent(Capture c) {
c.read();
if (mousePressed) {
for(int i = 0; i < song.left.size() – 1; i++) {
rect(i, 50 + song.left.get(i)*50, i+1, 80 + song.left.get(i+1)*50);

} }

}

Advertisements
This entry was posted in Time-Based and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s