metronome

JavaScript
var bpm = 80;
setInterval(function() {
//play a sound
}, Math.round(60000 / bpm));
Source

Also in JavaScript: