Weierstrass

Another fractal. I don't know if I implemented it correctly. n should be infinity, but sonically it doesn't make much of a difference

Log in to post a comment.

ditty.bpm = 120;

input.a=.5; // min=0.01,max=0.99,step=.01
input.b=7; // min=7,max=99,step=2
input.n=10; // min=1,max=99,step=1

debug.log  ("Constraints met", a*b > 1. + 1.5*3.1415 );

const notes_m = scale(g4, scales['minor_pentatonic'], 3);


const osc2 = synth.def(
    class {
        constructor(options) {
            // The value of the note argument of the play call is retrievable via options.note.
            this.phase = 0;
        }
        
        process(note, env, tick, options) {
            var sum = 0.;
            for(let n=0; n<input.n; n++) {
                sum += Math.pow(input.a, n) * Math.cos(Math.pow(input.b, n)*3.1415*this.phase);
            }
            this.phase += midi_to_hz(note) * ditty.dt;
            return sum * env.value;
        }
    }, { xenv: 0.5, amp: 1, attack: 0.01, release: 0.3 }
);


loop( (loopCount) => {
    osc2.play(notes_m[loopCount%(notes_m.length-1)], { attack: 0.25, release: 1.,  duration: 0.5, pan: Math.random() * - .5, amp: 1.0 });
    sleep(1.);
}, { name: 'Weierstrass' });