Visual Music (Butthole Surfers – 22 Going on 23)

This was created in Processing.  A musical keyboard is used to show the images and sounds throughout the song.

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

int channel;
int pitch;
int velocity;

//images
PImage bg;
PImage one;
PImage two;
PImage three;
PImage four;
PImage five;
PImage six;
PImage seven;
PImage eight;
PImage nine;
PImage ten;
PImage eleven;
PImage twelve;
PImage thirteen;
PImage fourteen;
PImage fifteen;

//keypress
boolean four8;
boolean four9;
boolean five0;
boolean five1;
boolean five2;
boolean five3;
boolean five4;
boolean five5;
boolean five6;
boolean five7;
boolean five8;
boolean five9;
boolean six0;
boolean six1;
boolean six2;
boolean six3;
boolean six4;
boolean six5;
boolean six6;
boolean six7;
boolean six8;
boolean six9;
boolean seven0;
boolean seven1;
boolean seven2;
//end keypress

MidiBus myBus;
Minim minim;
AudioPlayer song;
AudioPlayer songone;
AudioPlayer songtwo;
AudioPlayer songthree;
AudioPlayer songfour;
AudioPlayer songfive;
AudioInput input;
FFT fft;

float a;
float ysize;
int step = 0;

void setup(){
size(720,720);
frameRate(30);

MidiBus.list();
myBus = new MidiBus(this, 0, 2);

//assign mp3s
minim = new Minim(this);
song = minim.loadFile(“Butthole Surfers.mp3”);
songone = minim.loadFile(“1.mp3”);
songtwo = minim.loadFile(“2.mp3”);
songthree = minim.loadFile(“3.mp3”);
songfour = minim.loadFile(“4.mp3”);
songfive = minim.loadFile(“5.mp3”);
song.play();
fft = new FFT(song.bufferSize(), song.sampleRate());

//load images
bg = loadImage(“bg.jpg”);
one = loadImage(“1.jpg”);
two = loadImage(“2.jpg”);
three = loadImage(“3.jpg”);
four = loadImage(“4.jpg”);
five = loadImage(“5.jpg”);
six = loadImage(“6.jpg”);
seven = loadImage(“7.jpg”);
eight = loadImage(“8.jpg”);
nine = loadImage(“9.jpg”);
ten = loadImage(“10.jpg”);
eleven = loadImage(“11.jpg”);
twelve = loadImage(“12.jpg”);
thirteen = loadImage(“13.jpg”);
fourteen = loadImage(“14.jpg”);
fifteen = loadImage(“15.jpg”);

}
//end setup

void draw(){

background(bg);

fft.forward(song.mix);

Note note = new Note(channel, pitch, velocity);

myBus.sendNoteOn(note);
myBus.sendNoteOff(note);

//keypresses make images
tint(255,a);
if(four8 == true){
image(one,0,0);
}
if(four9 == true){
songone.rewind();
songone.play();
}
if(five0 == true){
image(two,0,0);
}
if(five1 == true){
songtwo.rewind();
songtwo.play();
}
if(five2 == true){
image(three,0,0);
}
if(five3 == true){
image(four,0,0);
}
if(five4 == true){
songthree.rewind();
songthree.play();
}
if(five5 == true){
image(five,0,0);
}
if(five6 == true){
songfour.rewind();
songfour.play();
}
if(five7 == true){
image(six,0,0);
}
if(five8 == true){
songfive.rewind();
songfive.play();
}
if(five9 == true){
image(seven,0,0);
}
if(six0 == true){
image(eight,0,0);
}
if(six1 == true){
step = 1;
}
if(six2 == true){
image(nine,0,0);
}
if(six3 == true){
step = 2;
}
if(six4 == true){
image(ten,0,0);
}
if(six5 == true){
image(eleven,0,0);
}
if(six6 == true){
step = 3;
}
if(six7 == true){
image(twelve,0,0);
}
if(six8 == true){
step = 4;
}
if(six9 == true){
image(thirteen,0,0);
}
if(seven0 == true){
step = 5;
}
if(seven1 == true){
image(fourteen,0,0);
}
if(seven2 == true){
image(fifteen,0,0);
}

//fft grow
if(step == 0){
ysize = 5;
}else if(step == 1){
ysize = 50;
}else if(step == 2){
ysize = 100;
}else if(step == 3){
ysize = 1000;
}else if(step == 4){
ysize = 10000;
}else if(step == 5){
ysize = 100000;
}

//fft
stroke(random(255),random(255),random(255),200);
strokeWeight(6);
for(int i = 0; i < fft.specSize()+width; i += 6){
line (i, height + 6, i, height – fft.getBand(i)*ysize + 6);
}

}
//end draw

void noteOn(int channel, int pitch, int velocity){

//opacity
if(velocity > 0){
a = velocity * 2;
}

//assign images to keys
if(pitch == 48){
four8 = true;
}
if(pitch == 49){
four9 = true;
}
if(pitch == 50){
five0 = true;
}
if(pitch == 51){
five1 = true;
}
if(pitch == 52){
five2 = true;
}
if(pitch == 53){
five3 = true;
}
if(pitch == 54){
five4 = true;
}
if(pitch == 55){
five5 = true;
}
if(pitch == 56){
five6 = true;
}
if(pitch == 57){
five7 = true;
}
if(pitch == 58){
five8 = true;
}
if(pitch == 59){
five9 = true;
}
if(pitch == 60){
six0 = true;
}
if(pitch == 61){
six1 = true;
}
if(pitch == 62){
six2 = true;
}
if(pitch == 63){
six3 = true;
}
if(pitch == 64){
six4 = true;
}
if(pitch == 65){
six5 = true;
}
if(pitch == 66){
six6 = true;
}
if(pitch == 67){
six7 = true;
}
if(pitch == 68){
six8 = true;
}
if(pitch == 69){
six9 = true;
}
if(pitch == 70){
seven0 = true;
}
if(pitch == 71){
seven1 = true;
}
if(pitch == 72){
seven2 = true;
}
}
//end true

void noteOff(int channel, int pitch, int velocity){
four8 = false;
four9 = false;
five0 = false;
five1 = false;
five2 = false;
five3 = false;
five4 = false;
five5 = false;
five6 = false;
five7 = false;
five8 = false;
five9 = false;
six0 = false;
six1 = false;
six2 = false;
six3 = false;
six4 = false;
six5 = false;
six6 = false;
six7 = false;
six8 = false;
six9 = false;
seven0 = false;
seven1 = false;
seven2 = false;
}
//end false

//start console
void noteOn(Note note){
println();
println(“Note On:”);
println(“——–“);
println(“Channel:” + note.channel());
println(“Pitch:” + note.pitch());
println(“Velocity:” + note.velocity());
}
void noteOff(Note note) {
// Receive a noteOff
println();
println(“Note Off:”);
println(“———“);
println(“Channel:”+note.channel());
println(“Pitch:”+note.pitch());
println(“Velocity:”+note.velocity());
}
//end console

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