const linexp = (x,x0,x1,y0,y1) => y0 * (y1/y0) ** ((x-x0)/(x1-x0)); const linlin = (x,x0,x1,y0,y1) => y0 + (y1 - y0) * clamp01((x-x0)/(x1-x0)); const tri = synth.def((phase, env) => 1.22*(4.*Math.abs(phase % 1 - 0.5) - 1.) * env.value); const dist = synth.def((phase, env, tick, options) => Math.atan(25*(Math.abs(phase % 1 - 0.5) - 0.25) * env.value)); let rhythm = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.5,0.5]; let i = 0; loop( () => { // click sine.play((tick) => linlin(tick, 0, 0.03, 127, 0), {attack:0.0005, release:0.05, amp:0.1}); // boom sine.play( (tick) => linlin(tick, 0, 0.3, a1, f1), //{env: adsr2, attack:0.01, decay:0.1, decay_level:0.1, sustain:0.15, sustain_level:0.5, release:0.2, amp:2} {env: adsr, attack:0.26, release:0.2} ); // low thump tri.play( (tick) => linlin(tick, 0, 0.1, e3, f1), {env: adsr, attack:0.005, release:0.1} ); // high tump tri.play( (tick) => linlin(tick, 0, 0.03, a5, a3), {env: adsr, attack:0.005, release:0.03, amp:0.3} ); sleep(rhythm[i]); i = (i+1)%rhythm.length; }, {name:"kick"});