Processing Audio Project 10/11/16

Code:

import ddf.minim.*;
import ddf.minim.analysis.*;

Minim minim;
AudioPlayer music;
BeatDetect beat;
FFT fft;

int x = 40;
int y = 5;
int spacing = 5;
void setup(){
size (800,400);

minim = new Minim(this);

music = minim.loadFile(“SPONGEBOB – PANDA SPONGEBOB REMIX.mp3”, 1024);
music.play();

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

}

void draw(){

background(255,255,0);

beat.detect(music.mix);

for(int i = 0; i < music.bufferSize() – 1; i++)
{
strokeWeight(5);
stroke(242, 169, 27,60);
line(i, 50 + music.left.get(i)*50, i+1, 50 + music.left.get(i+1)*50);
line(i, 200 + music.left.get(i)*50, i+1, 200 + music.left.get(i+1)*50);
stroke(109,183,251,60);
line(i, 100 + music.right.get(i)*50, i+1, 100 + music.right.get(i+1)*50);
line(i, 250 + music.right.get(i)*50, i+1, 250 + music.right.get(i+1)*50);
stroke(221,228,246,60);
line(i, 150 + music.right.get(i)*50, i+1, 150 + music.right.get(i+1)*50);
line(i, 300 + music.right.get(i)*50, i+1, 300 + music.right.get(i+1)*50);
stroke(0,255,0,60);
line(i, 360 + music.left.get(i)*50, i+1, 360 + music.left.get(i+1)*50);
}

noStroke();

if (beat.isOnset() ){
fill(255,0,0);
ellipse (width/2, height/2, 400, 100);
}
if (beat.isOnset() ){
fill(255);
rect (275,150,100,50);
rect (425,150,100,50);
}
if (beat.isOnset() ){
fill(255,0,0);
triangle(400,350,350,300,450,300);
}
if (beat.isOnset() ){
fill(255,0,0);
quad(400,350,350,390,400,430,450,390);
}
if (beat.isOnset() ){
for (int y = 0; y < 400; y += spacing) {
fill(123,76,8);
rect(50, height, 100, height – fft.getBand(y)*3);
rect(650, height, 100, height – fft.getBand(y)*3);
rect(200, height, 100, height – fft.getBand(y)*2.5);
rect(00, height, 100, height – fft.getBand(y)*2.5);
}
if (beat.isOnset() ){
fill(255);
rect(75, height/2, 100, height – fft.getBand(y)*2);
rect(625, height/2, 100, height – fft.getBand(y)*2);
}
}
fft.forward(music.mix);
}

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