xxxxxxxxxx
38
let tempos = [25, 40, 70, 90, 110, 135, 165, 180, 240];
let t = 0;
let bpm;
let beat;
function preload() {
beat = loadSound('clock.mp3');
}
function setup() {
createCanvas(400, 400);
setTempo();
textAlign(CENTER, CENTER);
textSize(64);
frameRate(30);
}
function draw() {
background(0);
if(frameCount%int(30*60/bpm) == 0) {
background(255);
beat.play();
}
fill(255);
text(t, width/2, height/2);
}
function keyPressed() {
t++;
t %= tempos.length;
setTempo();
}
function setTempo() {
bpm = tempos[t];
}