Skip to content

Instantly share code, notes, and snippets.

@ltackett
Last active August 29, 2015 14:04
Show Gist options
  • Save ltackett/e68ce1f3392544dacb0e to your computer and use it in GitHub Desktop.
Save ltackett/e68ce1f3392544dacb0e to your computer and use it in GitHub Desktop.
Simple JavaScript examples
var BPM = 120;
var BPB = 4;
var msFromBPM = Math.round(60000/BPM);
setInterval(function(){
if (typeof(beat) === 'undefined') { beat = 1 };
if (beat === 1) { console.log('BLEEP', beat) }
else { console.log('bloop', beat) }
if (beat === BPB) { beat = 0 };
beat++;
}, msFromBPM);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment