Skip to content

Instantly share code, notes, and snippets.

@kaezarrex
Last active August 29, 2015 14:02
Show Gist options
  • Save kaezarrex/37929c8ceb4f0c479125 to your computer and use it in GitHub Desktop.
Save kaezarrex/37929c8ceb4f0c479125 to your computer and use it in GitHub Desktop.
Sanford And Son Theme Song
// 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