Audio Coding

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

Minim minim;
AudioPlayer player;
AudioInput input;
AudioPlayer song;
BeatDetect beat;

float eRadius;
float R;
float G;
float B;
float A;
color Color;
void setup()
{
size(512, 500);
frameRate(20);

minim = new Minim(this);

// specify 512 for the length of the sample buffers
// the default buffer size is 1024
song = minim.loadFile(“Stickerbrush.mp3”, 512);
song.play();
beat = new BeatDetect();

ellipseMode(RADIUS);
eRadius = random(20);
}

void draw()
{
stroke(random(255),random(255),random(255));
background(R, G, B, A);
// we draw the waveform by connecting neighbor values with a line
// we multiply each of the values by 50
// because the values in the buffers are normalized
// this means that they have values between -1 and 1.
// If we don’t scale them up our waveform
// will look more or less like a straight line.
for (int i = 1; i < song.bufferSize() – 1; i++)
{
line(i+1, 100 + song.left.get(i+1)*150, i+1, 150 + song.left.get(i+1)*150);
line(100 + song.right.get(i+1)*150, i+1, 150 + song.right.get(i+1)*150, i+1);
}
if (keyPressed) {

if (key== ‘h’) {
filter(ERODE);
}
if (key== ‘j’) {
filter(BLUR);
}
if (key== ‘k’) {
filter(DILATE);
}
}
Color=color(R,G,B,A);

beat.detect(song.mix);
float a = map(random(eRadius), 20, 80, 60, 255);
fill(random(255), random(255), random(255), random(a));
if ( beat.isOnset() ) eRadius = 80;
ellipse(width/eRadius, height/eRadius, eRadius, eRadius);
ellipse(width/eRadius, 2*eRadius, height/eRadius, eRadius);
eRadius *= 0.95;
if ( eRadius < 3.14 ) eRadius = 3.14;
}

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