Interactive Authoring: Visual Music

 

Processing Code:

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

Minim minim;
AudioPlayer player;

FFT fft;

void setup() {
size(800, 600);
colorMode(HSB, 360, 100, 100, 200);
noStroke();
smooth();
frameRate(200);

minim = new Minim(this);
player = minim.loadFile(“music.mp3”, 512);
fft = new FFT(player.bufferSize(), player.sampleRate());
player.play();
}

void draw() {
background(215,100,50);
int offset1 = 8;
int offset2 = 150;
int specSize = fft.specSize();

fft.forward(player.left);
for (int i = 0; i < specSize; i++) {
float h = map(i, 0, specSize, 0, 360);
int e_width = (int)((int)fft.getBand(i) * (h/offset1));
if (0 <= h && h <= 360 && e_width >= 10) {
int x = (int)random(0, 800);
for (int w = e_width; w > 0; w -= 2) {
fill(h, w-1 * 100 / e_width, 100, 50);
ellipse(x, h+offset2, w, w);
}}}

fft.forward(player.right);
specSize = fft.specSize();
for (int i = 0; i < specSize; i++) {
float h = map(i, 0, specSize, 0, 360);
int e_width = (int)((int)fft.getBand(i) * (h/offset1));
if (0 <= h && h <= 360 && e_width >= 10) {
int x = (int)random(0, 800);
for (int w = e_width; w > 0; w -= 2) {
fill(h, 100 – w * 100 / e_width, 100, 100);
ellipse(x, h+offset2, w, w);
}}}}

void keyPressed(){
if(player.isPlaying()){
player.pause();}
else{player.loop();
}}

void stop() {
player.close();
minim.stop();
super.stop();
}

Advertisements

About Yoko

I'm Yoko. I'm an international student from Japan. I love Japanese animation♡
This entry was posted in Interactive Authoring, 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