//Number 4 //Chuck a day 2009 //by Scott Hewitt //www.ablelemon.co.uk/chuckaday //Events for note on/off Event e; Event f; Event g; Event h; //int represents how many voices are sounding 0 => int stop; //signals score progression Event i; //synth function int set frequency, responds to event function void synthee (Event event, int xx){ SawOsc s => Envelope env => Pan2 p => dac; 0.3 => s.gain; 100::ms => env.duration; xx => s.freq; <<< xx >>>; while (true){ event => now; 0.8 => env.target; Std.rand2f(-1.0, 1.0) => p.pan; 1 => env.keyOn; stop++; <<< stop >>>; event => now; 0 => env.target; 1 => env.keyOff; stop--; } } //signal events function void control () { while (true){ if (maybe){ g.signal(); Std.rand2f(100, 800) * 1::ms => now; } if (maybe){ h.signal(); Std.rand2f(100, 800) * 1::ms => now; } if (maybe){ e.signal(); Std.rand2f(100, 800) * 1::ms => now; } if (maybe){ f.signal(); Std.rand2f(100, 800) * 1::ms => now; } } 1::ms => now; } //counts 20 seconds and then moves on score function void timer () { 20::second => now; i.signal(); } //create multiple voices using sporking spork ~ synthee(e, 500); spork ~ synthee(f, 800); spork ~ synthee(g, 1000); spork ~ synthee(h, 600); //Score ?? //counts 20 seconds spork ~ timer(); //changes synthee values spork ~ control(); //awaits signal to start end i => now; <<< "to end" >>> ; //waits for all notes to be off and ends while (stop != 0){ 1::ms => now; } //allows final envelope to end 101::ms => now;