<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Metronome</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: Arial, sans-serif;
}
#start {
padding: 10px 20px;
font-size: 18px;
}
</style>
</head>
<body>
<button id="start">Start Metronome</button>
<script>
let bpm = 45; // Start BPM
let beatCount = 0;
let interval;
function startMetronome() {
let intervalTime = 60000 / bpm;
interval = setInterval(() => {
playClick();
beatCount++;
// Increase BPM after every 64 beats
if (beatCount % 64 === 0) {
bpm += 3;
clearInterval(interval);
startMetronome(); // Restart metronome with new BPM
}
}, intervalTime);
}
function playClick() {
console.log('Click'); // You can replace this with a sound if needed
}
document.getElementById('start').addEventListener('click', () => {
if (!interval) {
startMetronome();
}
});
</script>
</body>
</html>