Interactive Authoring- Audio Homework

Code:

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;

Minim minim;
AudioPlayer Sans;
AudioInput input;
AudioPlayer player;
BeatDetect beat;
int counter;
int interval= 100;
color Sanz;

void setup () {
background (255);
size (512, 200);
Sanz = color (0, 0, 0);
minim = new Minim(this);
Sans= minim.loadFile (“Undertale.mp3”, 512);
Sans.play ();
beat = new BeatDetect();
}

void draw () {
if (mousePressed) {
background (150);
} else {
noStroke();
fill(150, 50);
rect(0,0,width,height);
}
beat.detect(Sans.mix);
counter++;
stroke (Sanz);
for (int i = 0; i < Sans.bufferSize() – 1; i++) { line(i, 50 + Sans.left.get(i)*50, i+1, 50 + Sans.left.get(i+1)*50); line(i, 150 + Sans.right.get(i)*50, i+1, 150 + Sans.right.get(i+1)*50); } if (beat.isOnset() && counter >= interval) {
Sanz = color (0, 0, 255);
}
if (beat.isOnset() && counter >= interval+100) {
Sanz = color (0);
}
if (beat.isOnset() && counter >= interval+200) {
Sanz = color (255);
counter=0;
}
}

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