xxxxxxxxxx
28
let kick;
let snare;
let hihat;
function preload() {
kick = loadSound("kick.mp3");
snare = loadSound("snare.mp3");
hihat = loadSound("hihat.mp3");
}
function setup() {
createCanvas(400, 400);
frameRate(32);
}
function draw() {
background(220);
if ((frameCount % 32 == 0) ||
(frameCount % 64 == 24)) {
kick.play();
}
if (frameCount % 32 == 16) {
snare.play();
}
if (frameCount % 8 == 0) {
hihat.play();
}
}