Song Program

song from Shelby Derck on Vimeo.

Program:

import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer song;
FFT fft;
BeatDetect beat;
float l;
int XE=20,YE=100;
void setup(){
size(512, 200,P3D);
background(0);

minim = new Minim(this);

song = minim.loadFile(“Achy Breaky Heart.mp3”, 512);
song.play();

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

beat = new BeatDetect();
rectMode(CENTER);
l = 10;
}
void draw(){
//fft-vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
fft.forward(song.mix);

for(int i = 0; i < fft.specSize(); i++){

//blueleft——————————————————————————-
stroke(0, 0, 255, 50);
line(i+XE, width/2, i, height/2 – fft.getBand(i)*50);

//CenterLines————————————————————————–

stroke(255, 0, 0, 50);
line(mouseX+XE, i-XE, i, height – fft.getBand(i)*30);

stroke(0,255,0,50);
line(mouseX+XE, i-XE, 512, height – fft.getBand(i)*30);

//randomright—————————————————————————-

line(256+i, height/2 – fft.getBand(i)*50, 256+i+XE, width/2);

//rects———————————————————————————
for(int X2=mouseX; X2<mouseX+5; X2++){
stroke(random(255),random(255),random(255));
fill(0,0,0,50);
rect(mouseX, height+80, i/30, height – fft.getBand(i)*100);
}}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//beat-vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
beat.detect(song.mix);
fill(0, 0, 0, 50);
stroke(random(255),random(255),random(255));
if ( beat.isOnset() ) l = 30;
rect(mouseX,mouseY + song.left.get(10)*5, l, l);
l*=0.60;
if(l<5) l=30;

for(int i = 0; i < song.left.size() – 1; i++){
if(keyPressed==true){
if(key==’z’){
int X=mouseX;int Y=mouseY;
if(X5 && Y>5){
line(i, 50 + song.left.get(i)*50, X+1, Y + song.left.get(Y+1)*50);
}
}
}
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
for(int i = 0; i < song.left.size() – 1; i++){
line(i, 150 + song.right.get(i)*50, i+1, 150 + song.right.get(i+1)*50);
}
//waveform-vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
stroke(random(255),random(255),random(255));
for(int i = 0; i < song.left.size() – 1; i++){
ellipse(i,0,10+song.left.get(i)*random(100), 10 + song.right.get(i)*random(100));
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}

Advertisements

About dercks

Shelby is a student at Alfred State College in Digital Media and Animation.
This entry was posted in Interactive Authoring, Uncategorized 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