[chuck-users] Musical Pieces (Bryan Green)

Perry R Cook prc at CS.Princeton.EDU
Thu May 29 15:05:19 EDT 2014


Bryan,

Here's a self-contained, single ChucK file,
version of "Smooth Criminal"

//****************************************************
// Smooth Criminal Tribute, by P. Cook, May 3, 2009
// because I should be doing more important things
// like reading Tom Lieber's Independent work final report :-)

0.1 => float tempo;

Mandolin bass1 => HalfRect clip => Gain main => dac;
Mandolin bass2 => clip;
bass1 => main;
bass2 => main;
Impulse kick => TwoPole kp => main;
50.0 => kp.freq; 0.99 => kp.radius; 0.1 => kp.gain;
Noise n => ADSR snare => TwoPole sp => Delay sdel => main;
200.0 => sp.freq; 0.9 => sp.radius; 0.1 => sp.gain;
snare.set(0.001,0.1,0.0,0.1);
(4.0 * tempo) :: second => sdel.max => sdel.delay;

0.3 => bass1.bodySize => bass2.bodySize;
0.03 => bass1.stringDetune;
0.03 => bass2.stringDetune;
0.05 => bass1.stringDamping;
0.05 => bass2.stringDamping;

SndBuf dope => main;
"special:dope" => dope.read;
0.0 => dope.gain;
SndBuf dope2 => main;
"special:dope" => dope2.read;
0.0 => dope2.gain;

Blit b => TwoPole p1 => Gain voice;
b => TwoPole p2 => voice;
b => TwoPole p3 => voice;
100 => b.harmonics;
0.998 => p1.radius => p2.radius => p3.radius;
0.03 => p1.gain; 0.01 => p2.gain; 0.01 => p3.gain;
0.0 => b.gain;
SinOsc vib => blackhole;
6.0 => vib.freq;

Std.mtof(60) => b.freq;
Std.mtof(64) => float bTarg;

doVerse(4);
doChorus(4);
spork ~ doMoogy(4);
doVerse(4);
doChorus(4);
spork ~ gliss();
doTag();
spork ~ fade();
spork ~ doMoogy(4);
doDopeVerse(4);

fun void doMoogy(int howmany) {
    Moog m => JCRev r => main;
    0.9 => m.filterQ;
    0.9 => m.filterSweepRate;
    0.05 => r.mix;
    15.0 => r.gain;
    [69, 71, 72, 74, 76, 78, 79, 81] @=> int scale[];
    0 => int measure;
    0 => int note;
    while (measure < howmany)  {
        0 => int note;
        while (note < 32)   {
            1 => m.noteOff;
            Std.mtof(scale[Std.rand2(0,7)]) => m.freq; 
            if (Std.rand2f(0.0,1.0) < 0.4) 1 => m.noteOn;
            tempo :: second => now;
            note++; 
        }
        measure++;
    }
    r =< main;
}

fun void doChorus(int howmany) {
    [64,64,64,64,64,64,67,64,64,64,67,64,64,64,62,60,59,60] @=> int dopes[];
    [ 1, 1, 1, 1, 1, 1, 2, 4, 1, 1, 2, 4, 1, 1, 2, 2, 2, 2] @=> int ddurs[];
    0 => int measure;
    0 => int note;
    3.0 => dope.gain;
    while (measure < howmany)  {
        Std.mtof(41) => bass1.freq; 1 => bass1.noteOn;
        Std.mtof(41-12) => bass2.freq; 1 => bass2.noteOn;
        (2.0 * tempo) :: second => now;
        0 => int note;
        while (note < 18)   {
            1.03 * (Std.mtof(dopes[note]) / Std.mtof(67)) => dope.rate;
            0 => dope.pos;
            (tempo*ddurs[note]) :: second => now;
            note++; 
        }
        measure++;
    }
}

fun void doVerse(int howmany) {
    [45,45,45,45,45,45,45,47,47,47,47,48,48,48,48,47,43,40,45] @=> int notes[];
    [ 2, 1, 1, 1, 1, 1, 1, 2, 4, 1, 1, 2, 4, 1, 1, 2, 2, 2, 2] @=> int durs[];
    [ 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0] @=> int kicks[];
    [ 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0] @=> int snares[];
    0 => int note;
    0 => int measure;
    while (measure < howmany) {
        Std.mtof(notes[note]) => bass1.freq;
        Std.mtof(notes[note]-12) => bass2.freq;
        1 => bass1.noteOn;
        1 => bass2.noteOn;
        if (kicks[note]==1) 1 => kick.next;
        if (snares[note]==1) 1 => snare.keyOn;
        (durs[note] * tempo/2.0) :: second => now;
        0 => bass1.noteOn => bass2.noteOn;
        1 => snare.keyOff;;
        (durs[note] * tempo/2.0) :: second => now;
        note++;
        if (note==19) {
            0 => note;
            measure++; 
        }
    }
}
    
fun void doTag() {
        [64,60,62,64,40,64,60,62,64,40] @=> int dopes2[];
        [ 2, 2, 2, 2, 4, 2, 2, 2, 2, 4] @=> int ddurs2[];
        0 => int measure;
        0 => int note;
        3.0 => dope.gain;
        3.0 => dope2.gain;
        while (note < 10)   {
            1.03 * (Std.mtof(dopes2[note]) / Std.mtof(67)) => dope2.rate;
            dope2.rate()*2.0 => dope.rate;
            0 => dope2.pos;
            0 => dope.pos;
            (tempo*ddurs2[note]) :: second => now;
            note++; 
        }
        0.0 => dope2.gain;
        
        Noise n => main;
        0.1 => n.gain;
        0.07 :: second => now;
        n =< main;
        0.03 :: second => now;
        
        4.0 => b.gain;
        voice => main;
        
        Std.mtof(76) => dope2.rate;
        0 => dope2.pos;
        
        0.4 :: second => now;
        300.0 => p1.freq; 900.0 => p2.freq; 2300.0 => p3.freq;
        
        Std.mtof(62) => bTarg;
        0.1 :: second => now;
        360.0 => p1.freq; 2000.0 => p2.freq; 2600.0 => p3.freq;
        0.03 => p1.gain; 0.03 => p2.gain; 0.03 => p3.gain;
        
        Std.mtof(60) => bTarg;
        0.1 :: second => now;
        700.0 => p1.freq; 1100.0 => p2.freq; 2500.0 => p3.freq;
        
        Std.mtof(57) => bTarg;
        0.2 :: second => now;
        700.0 => p1.freq; 1200.0 => p2.freq; 2500.0 => p3.freq;

        0.0 => b.gain;
        voice =< main;
    }
    
fun void gliss() {
    while (1) {
        (0.01* bTarg) + (0.99 * b.freq()) => b.freq;
        0.0005 :: second => now;
    }
}

fun void fade() {
    while (1) {
        (0.985 * main.gain()) => main.gain;
        0.04 :: second => now;
    }    
}

fun void doDopeVerse(int howmany) {
    [45,45,45,45,45,45,45,47,47,47,47,48,48,48,48,47,43,40,45] @=> int notes[];
    [ 2, 1, 1, 1, 1, 1, 1, 2, 4, 1, 1, 2, 4, 1, 1, 2, 2, 2, 2] @=> int durs[];
    [ 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0] @=> int kicks[];
    [ 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0] @=> int snares[];
    0 => int note;
    0 => int measure;
    3.0 => dope.gain;
    while (measure < howmany) {
        Std.mtof(notes[note]) => bass1.freq;
        4.1 * (Std.mtof(notes[note]) / Std.mtof(67)) => dope.rate;
        0 => dope.pos;        
        Std.mtof(notes[note]-12) => bass2.freq;
        1 => bass1.noteOn;
        1 => bass2.noteOn;
        if (kicks[note]==1) 1 => kick.next;
        if (snares[note]==1) 1 => snare.keyOn;
        (durs[note] * tempo/2.0) :: second => now;
        0 => bass1.noteOn => bass2.noteOn;
        1 => snare.keyOff;;
        (durs[note] * tempo/2.0) :: second => now;
        note++;
        if (note==19) {
            0 => note;
            measure++; 
        }
    }
}



More information about the chuck-users mailing list