Last active
August 29, 2015 14:02
-
-
Save kaezarrex/37929c8ceb4f0c479125 to your computer and use it in GitHub Desktop.
Sanford And Son Theme Song
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
// http://wavepot.com/ | |
var b = makeNote(987.77); | |
var a = makeNote(880); | |
var fSharp = makeNote(739.99); | |
var f = makeNote(698.46); | |
var d = makeNote(587.33); | |
var _ = makeNote(0); | |
var rate = 4; | |
var song = [_, d, d, b, a, _, _, _, _, d, d, b, a, f, fSharp, d]; | |
function makeNote(f) { | |
return function(t) { | |
return Math.sin(2 * Math.PI * t * f); | |
} | |
} | |
function dsp(t) { | |
var result = 0; | |
var u = t * rate; | |
var index = Math.floor(u) % song.length; | |
if (u - Math.floor(u) > 0.8) return 0; | |
return 0.5 * song[index](t); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment