xxxxxxxxxx
154
function preload() {
Kick = loadSound("drums/kick.mp3");
Snare = loadSound("drums/snare.mp3");
Hh = loadSound("drums/hh.mp3");
Clap = loadSound("drums/clap.mp3");
for (let i=1; i<8; i++) {
Chords[i] = loadSound("chords/chord"+i+[".mp3"])
}
for (let i=1; i<6; i++) {
Bass[i] = loadSound("bass/bass"+i+[".mp3"])
}
}
function setup() {
createCanvas(windowWidth,windowHeight);
kickBlock = new Sound("kick");
snareBlock = new Sound("snare");
hhBlock = new Sound("hh");
clapBlock = new Sound("clap");
chord = new Sound("chord");
bass = new Sound("bass");
}
function draw() {
// const uD = new Date();
// let uN = uD.getTime();
background(100);
chord.display();
bass.display();
kickBlock.analyze();
kickBlock.display();
snareBlock.analyze();
snareBlock.display();
hhBlock.analyze();
hhBlock.display();
clapBlock.analyze();
clapBlock.display();
instructionsText();
// console.log(n);
}
function mousePressed() {
instructions = !instructions;
}
function keyPressed() {
pressed = false;
if (key == 'a') {
kickBlock.play();
pressed = true;
}
if (key == 'f') {
snareBlock.play();
}
if (key == 'w') {
hhBlock.play();
}
if (key == 'e') {
clapBlock.play();
pressed = true;
}
if (keyCode == RIGHT_ARROW){
chord = new Sound("chord",int(random(1,6)));
if (c < 9 && c>0){
chord.play();
c++
}
if (c==8 || c==0) {
c = 0;
chord.play();
c++;
}
// console.log(c + "right")
}
if (keyCode === LEFT_ARROW) {
chord = new Sound("chord",int(random(1,6)));
if (c < 9 && c>0){
chord.play();
c--
}
if (c==8 || c==0) {
c = 8;
chord.play();
c--;
}
// console.log(c + "left")
}
if (keyCode === UP_ARROW) {
chord = new Sound("chord",int(random(1,6)));
chord.play();
// console.log(c + "up");
}
if (keyCode === DOWN_ARROW) {
chord = new Sound("chord",int(random(1,6)));
c = int(random(1,8));
chord.play();
// console.log(c+"down");
}
if (keyCode === 32) {
bass = new Sound("bass");
b = int(random(1,6));
bass.play();
pressedBass = !pressedBass;
console.log(b+"bass");
}
// console.log(chord.selection+"selection");
// // console.log("sound =" + );
}
function instructionsText (){
if (instructions == true){
fill(255);
text("Press A,W,E,F for DRUMS. Press SPACE for BASS. Press the ARROWS for CHORDS. Press mouse to close instructions",.15*width,50, .75*width,.4*height)
}
}