Heartbeat

Chill

Log in to post a comment.

const heart = synth.def(
    class {
        constructor(options) {
            this.phase = 0;
        }
        process(note, env, tick, options) {
            this.phase += midi_to_hz(note) * ditty.dt * (env.value ** options.xenv);
            return Math.sin(this.phase * Math.PI * 2) * env.value;
        }
    }, { xenv: 0.5, amp: 2, attack: 0.01, release: 0.3, env: adsr2 }
);

loop( (beat) => {
    heart.play(c3, { attack: 0.01, release: 0.25, pan: (Math.random() * 2 - 1) * 0.25, amp: (beat % 8 == 0 ? 1 : ((beat % 8 == 2) ? 0.75 : 0)) });
    sleep( 0.25 );
});