-
-
Save NHQ/fd77d0c3e287998d8a00 to your computer and use it in GitHub Desktop.
INSTRUCTIONS: go to http://secret.synth.fm, erase the contents of the editor, paste this in, and hit shift-enter
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
oz = oscillators; | |
opts = {}; | |
var mm = 2 * 3 / 2; | |
var frequency = 220 * mm; | |
//opts.freq = 303; | |
var freqaa = [202, 303, 101, 404, 303, 101, 606, 1212, 909, 505, 101, 404, 303]; | |
var tempos = [2, 4, 1, 8, 16, 1/2] | |
setInterval(function(){ | |
frequency = freqaa[Math.floor(time * 8 % 13)] * mm / 2 / 2 | |
}, 10) | |
opts.c = 1000; | |
opts.a = 1; | |
opts.m = 2; | |
opts.wave = 'sine'; | |
global.Delay = delay(sampleRate * 2, 1, .9); // comment this out after first compile | |
dingdong = makeBells(opts); | |
synth = function(){ | |
opts.m = 4 + ( .01 * ( 1 + sine(time, 1/128))); | |
// opts.a = .85 + ( .4 * ( 1 + sine(time, 1/4))); | |
opts.c = 100 + ( 33 * ( 1 + sine(time, 1/64))); | |
return global.Delay(dingdong(time, opts.m, opts.c, opts.a) * .2, sampleRate * (4 * (time % 1/4)), 1, 1) * 1000 / time | |
} | |
function makeBells(opts){ | |
opts = opts || {} | |
var f = opts.freq || opts.frequency || frequency || 0 // base frequency | |
var g = createGause(opts) | |
var m = opts.m || 2; | |
var wave = opts.wave || 'sine'; | |
return function(time, _m, c, a){ | |
var x = frequency, y = 0; | |
while(x <= 11000){ | |
y += (oz[wave](time, x) * g(x, c, a)); | |
x *= _m || m | |
} | |
return y | |
} | |
} | |
function createGause(opts){ | |
opts = opts || {} | |
var c = opts.c || 100 | |
var a = opts.a || 1 | |
return (function (delta, _c, _a){ | |
a = _a || a | |
c = _c || c | |
return + | |
a * | |
Math.pow( | |
Math.E, | |
( | |
-Math.pow( | |
delta - 0, | |
2 ) / | |
Math.pow( | |
32 * c, | |
2 ) | |
) | |
) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment