Created
April 9, 2014 20:09
-
-
Save morganherlocker/10309418 to your computer and use it in GitHub Desktop.
nuwave
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
var melody = [22,18,8,6,18,20,24,26,20,18,12,18] | |
return function (t) { | |
t = t/1.28 | |
return drums1(t)/4 + drums2(t)/2.4 + drums3(t)/18 + synth1(t) + synth2(t); | |
} | |
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