Skip to content

Instantly share code, notes, and snippets.

@morganherlocker
Created April 10, 2014 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morganherlocker/10336590 to your computer and use it in GitHub Desktop.
Save morganherlocker/10336590 to your computer and use it in GitHub Desktop.
eval_robot
var melody = [22,18,8,6,18,20,24,26,20,18,12,18,32,32,33,33,34,36,40,48,2,0,2,0,-32,-12,10,64]
return function (t) {
t = t/1.28
return drums1(t)/.05 + drums2(t)/.01 + drums3(t)/.043 + synth1(t)*400 + synth2(t)*280;
}
function sin (x, t) { return Math.sin(2 * Math.PI * t * x *.6) * 1.5 }
function drums1 (t) { return t % (1/2) < 1/10 ? 2*Math.random()-1 : 0}
function drums2 (t) { return t % (1/1) < 1/8 ? 2*Math.random()-1 : 0}
function drums3 (t) { return t % (1/8) < 1/32 ? 2*Math.random()-1 : 0}
function synth1 (t) {return sin(Math.pow(2, melody[Math.floor(t*8) % melody.length] / 24) * 100, t)}
function synth2(t) {return sin(Math.pow(2, melody[Math.floor(t*4) % melody.length] / 12) * 100, t)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment