Logistic map

Wait until gamma gets larger than 3.57...

Log in to post a comment.

input.gamma = 3.0; // min=3, max=3.999, step=0.01
input.attack = 0.04; // min=0.01, max=1, step=0.01
input.decay = 0.16; // min=0.01, max=1, step=0.01
input.sustain = 0.8; // min=0.01, max=1, step=0.01
input.release = 0.1; // min=0.01, max=1, step=0.01

const logisticMap = synth.def(class {
    constructor(options) {
        this.x0 = 0.5;
        this.x1 = 0.5;
        this.downsample = 1 / (2 * midi_to_hz(options.note) * ditty.dt);
        this.spl = this.downsample;
    }
    process(phase, env, tick, options) {
        const gamma = lerp(3, options.gamma, env.value);
        if(--this.spl <= 0) {
            this.spl += this.downsample;
            this.x0 = gamma * this.x0 * (1-this.x0);
            this.x1 = gamma * this.x1 * (1-this.x1);
        }
        const fixpoint = (gamma-1) / gamma;
        return [(this.x0 - fixpoint) * env.value,
                (this.x1 - fixpoint) * env.value];
    }
}, {gamma:3.3});

const nn = [c4,g4,d5,e5,a3,c5,e4,c5];

loop( (i) => {
    let gamma = input.gamma != 3.0 ? input.gamma : (1.999*Math.abs((i/200+0.5)%1 - 0.5) + 3);
    debug.warn("gamma",gamma);
    logisticMap.play(nn.ring(i), {
        attack: () => input.attack, 
        decay: () => input.decay,
        sustain: () => input.sustain,
        release: () => input.release,
        duration:1,
        gamma:gamma
    });
    sleep(0.5);
});