Created
December 15, 2013 23:20
-
-
Save sanaerosen/7979751 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<meta name="description" content="Blinkenlights" /> | |
<html> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
<script src="http://blinken.eecs.umich.edu/client.js"></script> | |
<body></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(new Blinken()).run(function () { | |
// substitute in your own score here! | |
var notes = [0,0,4,4,5,5,4,3,3,2,2,1,1,0, | |
4,4,3,3,2,2,1,4,4,3,3,2,2,1, | |
0,0,4,4,5,5,4,3,3,2,2,1,1,0]; | |
var beats = [1,1,1,1,1,1,2,1,1,1,1,1,1,2, | |
1,1,1,1,1,1,2,1,1,1,1,1,1,2, | |
1,1,1,1,1,1,2,1,1,1,1,1,1,2]; | |
var j = 0; | |
var octaves = 2; | |
var metronome = 700; | |
var pause = 200; | |
var on = true; | |
// Update lights one frame | |
return function (lights) { | |
var limit = (octaves * 8) * | |
Math.floor(lights.length/(octaves * 8)); | |
if (!on) { | |
for (i = 0; i < limit; i++) { | |
lights[i].a = 0; | |
} | |
on = true; | |
return pause; | |
} | |
for (i = 0; i < limit; i++) { | |
var i_mod = i % (8 * octaves); | |
lights[i].rgb(1,1,0); | |
if (i_mod == notes[j]) { | |
lights[i].a = 1; | |
} else { | |
lights[i].a = 0; | |
} | |
} | |
var time = beats[j] * (metronome - pause); | |
j += 1; | |
if (j == notes.length) { | |
j = 0; | |
} | |
on = false; | |
return time; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment