Visual Music

Drum Machine

Processing Code:

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
import net.java.games.input.*;
import org.gamecontrolplus.*;
import org.gamecontrolplus.gui.*;
Minim minim;
AudioPlayer player;
AudioPlayer play;
AudioPlayer kick;
AudioPlayer floor;
AudioPlayer ride;
AudioPlayer crash;
AudioPlayer high;
AudioPlayer low;
AudioPlayer groove;
AudioPlayer rock;

ControlIO control;
ControlDevice stick;
Configuration config;

float red;
float green;
float blue;
float a;
float diam;
float x;
float y;
public void setup() {
size (800, 450);
control = ControlIO.getInstance(this);
stick = control.getMatchedDevice(“DrumController1”);
minim = new Minim(this);
player = minim.loadFile(“ClosedHiHat.wav”);
play = minim.loadFile(“Snare.wav”);
kick = minim.loadFile(“Kick.wav”);
floor = minim.loadFile(“FloorTom1.wav”);
ride = minim.loadFile(“RideCymbal.wav”);
crash = minim.loadFile(“CrashCymbal.wav”);
high = minim.loadFile(“HiMidTom.wav”);
low = minim.loadFile(“LowMidTom.wav”);
groove = minim.loadFile(“Groove.mp3”);
rock = minim.loadFile(“Rock.mp3”);
}

void draw(){
background (255);
PImage img;
img = loadImage(“DrumSet.png”);
image(img, 0, 0);

if (stick.getButton(“L2”).pressed() == true){
play.rewind();
play.play();
red = random(255);
green = random(255);
blue = random(255);
noStroke();
fill(red,green,blue);
rect(447, 330, 80, 31, 7);
}

if (stick.getButton(“Left”).pressed() == true){
player.rewind();
player.play();
red = random(255);
green = random(255);
blue = random(255);
noStroke();
fill(red,green,blue);
triangle(537, 297, 574, 304, 500, 304);
triangle(537, 311, 574, 306, 500, 306);
}

if (stick.getButton(“R2”).pressed() == true){
kick.rewind();
kick.play();
red = random(255);
green = random(255);
blue = random(255);
noStroke();
fill(red,green,blue);
ellipse(429,408, 132, 133);
}
if (stick.getButton(“Down”).pressed() == true){
floor.rewind();
floor.play();
red = random(255);
green = random(255);
blue = random(255);
noStroke();
fill(red,green,blue);
rotate(0);
rect(290, 325, 80, 70);
rect(286, 315, 87, 23, 2);
rect(286, 387, 87, 16, 2);
}
if (stick.getButton(“R1”).pressed() == true){
ride.rewind();
ride.play();
pushMatrix();
red = random(255);
green = random(255);
blue = random(255);
noStroke();
fill(red,green,blue);
rotate(radians(14));
ellipse(370, 155, 111, 21);
popMatrix();
}
if (stick.getButton(“L1”).pressed() == true){
crash.rewind();
crash.play();
pushMatrix();
red = random(255);
green = random(255);
blue = random(255);
noStroke();
fill(red,green,blue);
rotate(radians(345));
ellipse(445, 342, 140, 25);
popMatrix();
}
if (stick.getButton(“O”).pressed() == true){
high.rewind();
high.play();
pushMatrix();
red = random(255);
green = random(255);
blue = random(255);
noStroke();
fill(red, green, blue);
quad(419, 285, 475, 275, 483, 315, 426, 325);
rotate(radians(350.5));
ellipse(394,350, 60, 15);
rotate(radians(360));
ellipse(395, 394, 60, 15);
popMatrix();
}
if (stick.getButton(“X”).pressed() == true){
low.rewind();
low.play();
pushMatrix();
red = random(255);
green = random(255);
blue = random(255);
noStroke();
fill(red,green,blue);
quad(353, 287, 419, 295, 415, 340, 348, 330);
rotate(radians(8));
ellipse(422, 232, 72, 17);
rotate(0.005);
ellipse(426, 278, 70, 15);
popMatrix();
}
if (stick.getButton(“Start”).pressed() == true){
groove.rewind();
groove.play();
}
if (stick.getButton(“Select”).pressed() == true) {
rock.rewind();
rock.play();
}
if (stick.getButton(“PS”).pressed() == true) {
rock.pause();
groove.pause();
}
}

For this project I decided to take a Playstation 3 controller and use it to play the different parts of a drum. Each button would play a different sound and then the “start” and “select” button are able to play a song that you can play the “drum” to. For the visual aspect of this project, I decided to make each button light up the corresponding part of the drum. It helps to connect the controller with an actual drum set and understand what each sound is.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s