Bell Tower

IT'S SUNDAY MORNING!

Log in to post a comment.

var modFactor = 2.01;
var modAmount = 5;

var lfoFreq = 3.32;
var lfoAmount = 0.0236;

const fmBell = synth.def(
    class {
        constructor(options) {
            this.phase = 0;
            this.modPhase = 0;
            this.lfoPhase = Math.random();
        }
        process(note, env) {
            var modFreq = midi_to_hz(note) * modFactor;
            this.modPhase += modFreq * ditty.dt;
            var modOsc = Math.sin(this.modPhase * Math.PI * 2);
            
            this.lfoPhase += lfoFreq * ditty.dt;
            var lfo = Math.sin(this.lfoPhase * Math.PI * 2);
            
            var carrierFreq = (midi_to_hz(note) + modOsc * modFreq * modAmount) * (1 + lfo * lfoAmount);
            this.phase += carrierFreq * ditty.dt;
            var carrierOsc = [Math.sin(this.phase * Math.PI * 2) * env.value, Math.sin(this.phase * Math.PI * 2 + 2.39996322972865332) * env.value];
            
            return carrierOsc;
        }
    }
);

loop( (loopCount) => {
    fmBell.play(c2, { attack: 0.01, release: 2, pan: (Math.random() * 2 - 1) * 0.25, amp: loopCount % 8 == 0 ? .5 : 0 });
    sleep( 0.5 + Math.random() / 20 );
});

loop( (loopCount) => {
    fmBell.play(c2, { attack: 0.01, release: 2, pan: (Math.random() * 2 - 1) * 0.25, amp: loopCount % 8 == 3 ? .5 : 0 });
    sleep( 0.5 + Math.random() / 20 );
});