Audio Visual Project

 

This video is a camera based interactive program made in Processing. I used a color tracking method that captures a certain color (the average of that color) and allow the main object(s) to move with the selected colored objects in real time. It is basically like using yourself or outside object as a virtual mouse. The music gives this program a happy, semi-chaotic moving aspect to it, as well as the colors.

code:

import ddf.minim.*;
import ddf.minim.analysis.*;
import processing.video.*;

Minim minim;
AudioPlayer song;
BeatDetect beat;
FFT fft;
Capture camera;

color tracked;
float threshold = 25;

float a;
float b;
float c;

int r;

PImage pic1;
PImage pic2;
PImage pic3;
PImage iseeyou;

void setup() {
size(1280, 720);

minim = new Minim(this);
song = minim.loadFile(“Libera Me From Hell Instrumental.mp3”, 2048);
song.play();

beat = new BeatDetect();
fft = new FFT(song.bufferSize(), song.sampleRate() );

camera = new Capture(this, 1280, 720, 30);
camera.start();
tracked = color(255, 0, 0);
}

void captureEvent(Capture camera) {
camera.read();
}

void draw() {
image(camera, 0, 0);
set(0, 0, camera);

float X = 0;
float Y = 0;

int numberPixels = 0;

for (int x = 0; x < camera.width; x++) {
for (int y = 0; y < camera.height; y++) {
int location = x + y * camera.width;

color current = camera.pixels[location];
float r = red(current);
float g = green(current);
float b = blue(current);
float r2 = red(tracked);
float g2 = green(tracked);
float b2 = blue(tracked);

float d = distance(r, g, b, r2, g2, b2);

if (d < threshold*threshold) {
X += x;
Y += y;
numberPixels++;
}
}
}

// BLACK BACKGROUND ———————————————

float m = millis();
m++;
if (m >= 5000) {
noStroke();
fill(0);
rect(0, 0, width*3, height*3);
}

// STATIC SHAPES ———————————————

if (beat.isOnset() ) {
filter(DILATE);
stroke(255);
noFill();
strokeWeight(3);
}

// BEGINNING SHAPES ———————————————

m++;
if (m <= 20000) {
if (numberPixels > 0) {
X = X/numberPixels;
Y = Y/numberPixels;
a = random(255);
b = random(255);
c = random(255);
noFill();
strokeWeight(2);
stroke(a, 0, c);
for (int i = 10; i <= 150; i *= 1.1) {
ellipse(X, Y, i, i);
}
}
m++;
a = random(255);
b = random(255);
c = random(255);
strokeWeight(3);
stroke(a, 0, c);
float p1 = random(width);
float p2 = random(height);
line(X, Y, p1, p2);
for (int i = 10; i <= 100; i *= 1.1) {
strokeWeight(2);
ellipse(p1, p2, i, i);
}
}

// FADING CIRCLES AND SHAPES ———————————————

m++;
if (m >= 20000 && m < 38500) {
if (beat.isOnset() ) {
fill(255);
noStroke();

rect(-25, height/2 + 30, 125, 25);
rect(-25, height/2 + 60, 150, 25);
rect(-25, height/2 + 90, 100, 25);
rect(-25, height/2 + 120, 50, 25);

rect(-25, height/2, 200, 25);

rect(-25, height/2 – 30, 125, 25);
rect(-25, height/2 – 60, 150, 25);
rect(-25, height/2 – 90, 100, 25);
rect(-25, height/2 – 120, 50, 25);

// —————————————-

rect(width+25, height/2 + 30, -125, 25);
rect(width+25, height/2 + 60, -150, 25);
rect(width+25, height/2 + 90, -100, 25);
rect(width+25, height/2 + 120, -50, 25);

rect(width+25, height/2, -200, 25);

rect(width+25, height/2 – 30, -125, 25);
rect(width+25, height/2 – 60, -150, 25);
rect(width+25, height/2 – 90, -100, 25);
rect(width+25, height/2 – 120, -50, 25);
}
}

m++;
if (m >= 20000 && m < 38500) {
if (numberPixels > 0) {
X = X/numberPixels;
Y = Y/numberPixels;
if ( frameCount % 2 == 0 ) {
filter( DILATE );
float radius = 200 + 150 * sin( frameCount * 0.05f );
a = random(255);
b = random(255);
c = random(255);
noStroke();
fill(a, 0, c, 100);
ellipse(X, Y, radius, radius);
}
if (m >= 20000 && m < 38500) {
if ( frameCount % 2 == 0 ) {
filter( DILATE );
float radius = 100 + 50 * sin( frameCount * 0.05f );
a = random(255);
b = random(255);
c = random(255);
noStroke();
fill(a, 0, c, 200);
ellipse(X+25, Y, radius, radius);
ellipse(X-25, Y, radius, radius);
ellipse(X, Y+25, radius, radius);
ellipse(X, Y-25, radius, radius);
}
if (m >= 20000 && m < 38500) {
if ( frameCount % 2 == 0 ) {
filter( DILATE );
float radius = 50 + 25 * sin( frameCount * 0.05f );
a = random(255);
b = random(255);
c = random(255);
noStroke();
fill(a, 0, c);
ellipse(X+75, Y, radius, radius);
ellipse(X-75, Y, radius, radius);
ellipse(X, Y+75, radius, radius);
ellipse(X, Y-75, radius, radius);
}
a = random(255);
b = random(255);
c = random(255);
noStroke();
fill(a, 0, c);
filter(ERODE);
ellipse(X+150, Y, 40, 40);
ellipse(X-150, Y, 40, 40);
ellipse(X, Y+150, 40, 40);
ellipse(X, Y-150, 40, 40);
ellipse(X+100, Y+100, 40, 40);
ellipse(X-100, Y-100, 40, 40);
ellipse(X+100, Y-100, 40, 40);
ellipse(X-100, Y+100, 40, 40);
}
}
}
}
// WAVE THINGS ———————————————

beat.detect(song.mix);
fft.forward(song.mix);
m++;
float alpha2 = 100;
if (beat.isOnset() ) {
if (m > 39000) {
for (int M = 0; M < song.bufferSize() – 1; M++) {
stroke(a, 0, c, alpha2);
line(M, 0 + song.left.get(M)*5, M, 40 + song.right.get(M)*5);
line(M, height + song.left.get(M)*5, M, height-40 + song.right.get(M)*5);
alpha2 = random(100);
}
}
}

m++;
if (m > 39000) {
if (numberPixels > 0) {
X = X/numberPixels;
Y = Y/numberPixels;
a = random(255);
b = random(255);
c = random(255);

filter(INVERT);
noFill();
stroke(a, 0, c);
strokeWeight(3);
rectMode(CENTER);
float rec = 150 + 25 * sin( frameCount * 0.05f );
float rec2 = 200 – 25 * sin( frameCount * 0.05f );
float rec3 = 100 – 50 * sin( frameCount * 0.05f );
float rec4 = 100 + 35 * sin( frameCount * 0.05f );
rect(X, Y, rec, rec);
rect(X, Y, rec2, rec2);
rect(X, Y, rec3, rec3);
rect(X, Y, rec4, rec4);

strokeWeight(5);
filter(DILATE);
float rec5 = 250 + 25 * sin( frameCount * 0.05f );
float rec6 = 200 + 50 * sin( frameCount * 0.05f );
rect(X, Y, rec5, rec5);
rect(X, Y, rec6, rec6);

rect(X, Y, 300, 300);

line(X-150, Y-150, 0, 0);
line(X+150, Y-150, width, 0);
line(X+150, Y+150, width, height);
line(X-150, Y+150, 0, height);
}
}
}
void mousePressed() {
int location = mouseX + mouseY * camera.width;
tracked = camera.pixels[location];
}

float distance (float x1, float y1, float z1, float x2, float y2, float z2) {
float d = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-x1)*(z2-z1);
return d;
}
// Color Tracking Referenced From Daniel Shiffman

// https://www.youtube.com/watch?v=WH31daSj4nc
// https://www.youtube.com/watch?v=nCVZHROb_dE&list=PLRqwX-V7Uu6bw0bVn4M63p8TMJf3OhGy8&index=5

———————————————————————————————————-

Progress on my Visual Music project in Processing:

My original idea and code that i had was that of a program that detects edges and blobs. I was going to incorporate that into visual music somehow; however, I changed the idea and now have new code, which is further down the page.

screen-shot-2016-10-21-at-10-11-44-am screen-shot-2016-10-21-at-10-12-39-am

screen-shot-2016-10-21-at-10-12-54-am

My new concept incorporates camera movement and motion/color tracking. When I click on a certain color, objects and designs track that color around. There are also certain things happening elsewhere on the screen, giving this interactive piece more, constant movement.

screen-shot-2016-10-27-at-9-30-44-pm screen-shot-2016-10-27-at-9-31-00-pm screen-shot-2016-10-27-at-9-31-30-pm screen-shot-2016-10-27-at-9-31-52-pm

 

Advertisements
This entry was posted in Interactive, 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