// Fairly silly program to synthesize the // word "chuck" in ChucK. Perry Cook, Nov. 2007 // updated Oct. 2009, CC //---------------------- // declare all unit generators (keep as is) Noise n; // fricative noise source Envelope ne; // noise envelope Impulse i; // glottal pulse source OnePole o; // glottal low-pass filter Envelope ie; // impulse amplitude envelope TwoPole r[3]; // resonator filters TwoZero z; // DC blocker filter int buzzOn; // flag for buzz state // "homemade" buzz source fun void buzz() { 150.0 => float freq; // initial buzz period while (buzzOn) { // still buzzing? 1.0 => i.next; // trigger one impulse (1.0 / freq) :: second => now; // time to wait freq * 0.98 => freq; // lengthen buzz period } } // the patch (keep as is) // noise into resonators into output n => ne => r[0] => z => dac; ne => r[1] => z; ne => r[2] => z; // and glottal source into resonators i => o => ie => r[0]; ie => r[1]; ie => r[2]; // set constant parameters (keep as is) 0.99 => o.pole; 10.0 => o.gain; 1.0 => z.b0; 0.0 => z.b1; -1.0 => z.b2; fun void ch(float duration, float volumn) { <<< "ch" >>>; if(volumn != -1){ volumn => ne.gain; } 0.03=>ne.time; // envelope slew rate // resonators 1900.0 => r[0].freq; 0.99 => r[0].radius; 1.0 => r[0].gain; 2700.0 => r[1].freq; 0.99 => r[1].radius; 0.7 => r[1].gain; 3200.0 => r[2].freq; 0.99 => r[2].radius; 0.8 => r[2].gain; 0.0 => i.gain; // no glottal 0.02 => n.gain; // noise 1=>ne.keyOn; // trigger envelope rise //0.03 :: second => now; duration::second => now; 1=>ne.keyOff; // trigger envelope decay 0.03 :: second => now; } fun void uh(float duration, float volumn) { <<< "uh" >>>; if(volumn != -1){ volumn => ie.gain; }0.1=>ie.time; 0.0 => n.gain; 600.0 => r[0].freq; 0.995 => r[0].radius; 1.0 => r[0].gain; 1500.0 => r[1].freq; 0.995 => r[1].radius; 0.5 => r[1].gain; 3900.0 => r[2].freq; 0.99 => r[2].radius; 0.2 => r[2].gain; 1 => buzzOn; spork ~ buzz(); 1.0 => i.gain; 1 => ie.keyOn; //0.1 :: second => now; duration::second => now; 1 => ie.keyOff; 0.1 :: second => now; 0 => buzzOn; } fun void ck(float duration, float volumn) { <<< "ck" >>>; if(volumn != -1){ volumn => ne.gain; } 0.0 => i.gain; 0.05 :: second => now; 0.005=>ne.time; 0.007 => n.gain; 380.0 => r[0].freq; 0.99 => r[0].radius; 0.7 => r[0].gain; 1700.0 => r[1].freq; 0.99 => r[1].radius; 1.0 => r[1].gain; 4500.0 => r[2].freq; 0.99 => r[2].radius; 0.7 => r[2].gain; 1 => ne.keyOn; //0.005 :: second => now; duration::second => now; 1 => ne.keyOff; 0.01=>ne.time; 0.01 :: second => now; } fun void ring1(){ for(0 => int k; k < 5; k++){ for(0=> int j; j < 10; j++){ ch(0.1, k+2); } for(0 => int i; i <= k; i++) ck(0.1, 5); 1.0::second => now; } uh(2, 2); } fun void ring2(){ for(0 => int k; k < 4; k++){ ch(0.1, 5); ck(0.1, 5); ck(0.1, 5); ck(0.1, 5); ch(0.1, 5); 0.5::second => now; ch(0.1, 5); ck(0.1, 5); ck(0.1, 5); ch(0.3, 5); 0.5::second => now; ck(0.1, 5); ck(0.1, 5); ck(0.1, 5); ch(0.2, 5); 1.0::second => now; } } fun void ring3(){ for(0 => int k; k < 2; k++){ ck(1.,5); ch(0.2, 8); 1::second => now; ck(1.,5); ch(0.1, 8); ch(0.1, 8); 1::second => now; ch(0.1,5); 0.2::second => now; ch(0.1,5); ch(0.1,5); ch(0.1,5); 0.1::second => now; ch(0.1,5); 0.2::second => now; ch(0.2,5); 0.1::second => now; ch(0.1,8); 1::second => now; } ch(0.03, -1); uh(0.1, -1); ck(0.001, -1); } // say ring3();