ChucK, ep. 1

It has been on my to-do list for a few years to learn ChucK. Due to a recent knee injury that is preventing me from using stairs and therefore accessing my studio, I have decided to cross off that to-do item.

This is a simple ChucK program I wrote after doing the moe/larry/curly tutorial. Depending on how you tweak moe, larry and curly, you can get a modulated impulse arpeggio, a modulated buzz, or something funky in-between.

// moe
Impulse moe_impulse => BiQuad moe_filter => dac;
.99 => moe_filter.prad; // Goes off the rails and farts itself out at 1.0
1 => moe_filter.eqzs;
5123.0 => float moe_sweep; // Sweeps up to this freq
0.05 => float moe_inc;

// larry
Impulse larry_impulse => BiQuad larry_filter => dac;
.99 => larry_filter.prad;
1 => larry_filter.eqzs;
500.0 => float larry_sweep;
0.06 => float larry_inc;
// Create mathematical relationship between larrylater and larrytimepass
2.3 => float larrylater;
larrylater/1.1 => float larrytimepass;

// curly
Impulse curly_impulse => BiQuad curly_filter => dac;
.99 => curly_filter.prad;
1 => curly_filter.eqzs;
4000.0 => float curly_sweep;
1.03 => float curly_inc;
2.0 => float curlylater;
curlylater/.02 => float curlytimepass;

// all
0.0 => float v;

while(true){
    // Softer at values less than 1.0
    1.0 => moe_impulse.next;
    Std.fabs(Math.sin(v)) * moe_sweep => moe_filter.pfreq;
    // Smaller = more gentle sweep, larger = faster but more quantized sweep
    v + moe_inc => v;
    now + larrylater::ms => time later;
    while(now < later){
        1.0 => larry_impulse.next;
        Std.fabs(Math.sin(v)) * larry_sweep => larry_filter.pfreq;
        v + larry_inc => v;
        larrytimepass::ms => now;
        now + curlylater::ms => time evenlater;
        while(now < evenlater){
            1.0 => curly_impulse.next;
            Std.fabs(Math.sin(v)) * curly_sweep => curly_filter.pfreq;
            v + curly_inc => v;
            curlytimepass::ms => now;
        }
    }
    10::ms => now;
}

Comments

Popular Posts