// lower dac gain 0.1 => dac.gain; // define eighth note for melodic syncing 250 => int eighth; // set up unit generators SawOsc s1 => ADSR e1 => Chorus c => NRev r => Gain g => dac; SqrOsc s2 => ADSR e2 => c => r => g => dac; SawOsc s3 => ADSR e3 => c => r => g => dac; Shakers shk => dac; // configure reverb and ugen mixing c.mix(0.05); r.mix(0.04); 0.06 => g.gain; 0.7 => s2.gain; // set envelope parameters e1.set(5::ms, 4*eighth::ms, 0, 0::ms); e2.set(5::ms, 3*eighth::ms, 0, 0::ms); e3.set(5::ms, 4*eighth::ms, 0, 0::ms); // define a function that plays a melody given note frequency and duration arrays fun void play(int n[], int d[], Osc s, ADSR e) { for (0 => int i; i < n.cap(); i++) { n[i] => Std.mtof => s.freq; e.keyOn(); d[i]*eighth::ms => now; } } // shaker pattern fun void shakers() { shk.preset(6); 1.65 => shk.gain; for (0 => int i; i < 8; i++) { shk.noteOn(50); eighth::ms => now; shk.noteOff(50); } } // introductory pattern for s1 fun void zero() { [48, 50, 48, 53, 55, 53, 52, 50] @=> int n[]; [2, 2, 2, 2, 5, 1, 1, 1] @=> int d[]; play(n, d, s1, e1); } // first repeated pattern for s1 fun void one() { [48, 50] @=> int n[]; [3, 5] @=> int d[]; play(n, d, s1, e1); } // first repeated pattern for s2 fun void two() { [67, 65, 64, 60] @=> int n[]; [1, 3, 1, 3] @=> int d[]; play(n, d, s2, e2); } // first repeated pattern for s3 fun void three() { [76, 74, 72, 76, 72] @=> int n[]; [1, 1, 2, 1, 3] @=> int d[]; play(n, d, s3, e3); } // final chord of s1, s2, s3 fun void four() { e1.set(5::ms, 0::ms, 1, 8*eighth::ms); e2.set(5::ms, 0::ms, 1, 8*eighth::ms); e3.set(5::ms, 0::ms, 1, 8*eighth::ms); [55, 53, 52, 50, 52] @=> int n1[]; [2, 2, 2, 2, 8] @=> int d1[]; [60] @=> int n2[]; [8] @=> int d2[]; [74, 76] @=> int n3[]; [2, 6] @=> int d3[]; spork ~ play(n1, d1, s1, e1); spork ~ play(n2, d2, s2, e2); spork ~ play(n3, d3, s3, e3); } // run the routines zero(); spork ~ shakers(); spork ~ one(); 8*eighth::ms => now; spork ~ shakers(); spork ~ one(); 8*eighth::ms => now; spork ~ shakers(); spork ~ one(); spork ~ two(); 8*eighth::ms => now; spork ~ shakers(); spork ~ one(); spork ~ two(); 8*eighth::ms => now; spork ~ shakers(); spork ~ one(); spork ~ two(); spork ~ three(); 8*eighth::ms => now; spork ~ shakers(); spork ~ one(); spork ~ two(); spork ~ three(); 8*eighth::ms => now; four(); spork ~ one(); spork ~ three(); 16*eighth::ms => now; // end the chord e1.keyOff(); e2.keyOff(); e3.keyOff(); 24*eighth::ms => now;