Heart Break

CODE:
import ddf.minim.*;
import ddf.minim.analysis.*;

Minim minim;
AudioPlayer song;
FFT fft;
BeatDetect beat;
float eRadius;

void setup()
{
noCursor();
size(512, 700);
minim = new Minim(this);

song = minim.loadFile(“You’re Gonna Go Far, Kid.mp3”, 2048);
song.play();

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

void draw()
{
background(0);
fft.forward(song.mix);

background(0);
beat.detect(song.mix);
float a = map(eRadius, 20, 80, 60, 255);
//eye
stroke(255);
fill(0);
if ( beat.isOnset() ) eRadius = 80;

fill (255, 20, 20, eRadius);
stroke (255, 20, 20);
rectMode (CENTER);
rect (mouseX, mouseY, 20, 20);
rect (mouseX+20, mouseY-20, 20, 20);
rect (mouseX-20, mouseY-20, 20, 20);
rect (mouseX, mouseY+40, 20, 20);
rect (mouseX+20, mouseY, 20, 20);
rect (mouseX, mouseY+20, 20, 20);
rect (mouseX+20, mouseY+20, 20, 20);
rect (mouseX-20, mouseY+20, 20, 20);
rect (mouseX-40, mouseY, 20, 20);
rect (mouseX+40, mouseY, 20, 20);
rect (mouseX-20, mouseY, 20, 20);
fill(255, 20, 20, 10);
ellipse(mouseX, mouseY, eRadius, eRadius);

eRadius *= 0.95;
if ( eRadius < 20 ) eRadius = 40;

stroke(255, 128);
for (int i = 0; i < fft.specSize(); i++)
{
stroke (255, 20, 20);
line(i, width, i, height – fft.getBand(i)*25);
line(i, 0, i, 0 + fft.getBand(i)+5);

line(i, 50 + song.left.get(i)*50, i+1, 50 + song.left.get(i+1)*50);

line(i, 450 + song.right.get(i)*50, i+1, 450 + song.right.get(i+1)*50);
stroke (0);
line(i, 600 + song.right.get(i)*50, i+1, 610 + song.right.get(i+1)*50);
}

//filter (DILATE);
//filter (ERODE);
}

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