import processing.sound.*;
// declare three SoundFile objects
SoundFile kick;
SoundFile snare;
SoundFile hihat;
int a = 70;
int b = 60;
int c= 50;
int d = 20;
float e = 20;
void setup() {
size(640, 480);
// create the objects and load sounds into them
kick = new SoundFile(this, “kick.wav”);
snare = new SoundFile(this, “snare.wav”);
hihat = new SoundFile(this, “hihat.aif”);
}
void draw() {
background(0);
//for kick
for (int x=0; x<width; x =x + a) {
for (int y=0; y<height; y =y+ a) {
a = 70;
stroke(#3bceac);
line(x, 0, x, 480);
line(0, y, 640, y);
if (key==’k’) {
a=110;
e=e-0.000000000001;
//goUp();
}
} // for loop 2
}// for loop 1
//for snare
for (int x=0; x<width; x =x + b) {
for (int y=0; y<height; y =y+ b) {
b = 60;
stroke(#ee4266);
line(x, 0, x, 480);
line(0, y, 640, y);
if (key==’s’) {
b=90;
//goUp();
}
} // for loop 2
}// for loop 1
//for high hat
for (int x=0; x<width; x =x + c) {
for (int y=0; y<height; y =y+ c) {
c = 50;
stroke(#540d6e);
line(x, 0, x, 480);
line(0, y, 640, y);
if (key==’h’) {
c=100;
//goUp();
}
} // for loop 2
}// for loop 1
}
void keyPressed() {
// when a key is pressed, use a switch statement
// to determine which key was pressed
// and play the appropriate sound file and set a background color
switch(key) {
case ‘k’:
kick.play();
e=e-1;
break;
case ‘s’:
snare.play();
break;
case ‘h’:
hihat.play();
break;
}
}
//void goUp(){
//e=e-1;
//}
Leave a Reply
You must be logged in to post a comment.