Skip to content

Instantly share code, notes, and snippets.

@kaezarrex kaezarrex/SaS.js
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.