//Example using a custom event class //Conductor decides how many subdivisions and beat length //uses a MyEvent object (from customEventClass.ck) to //communicate this info to the players at the time the event is broadcast. MyEvent e; spork ~conductor(); spork ~player1(); spork ~player2(); while(true) { 1::hour => now; } fun void conductor() { while (true) { Std.rand2f(1,2)::second => e.beatLength; //Can change/randomize this 3 => e.numSubdivisions; e.broadcast(); e.beatLength => now; } } fun void player1() { dur mySubdivisionDur; Mandolin m => dac; while (true) { e => now; e.beatLength / e.numSubdivisions => mySubdivisionDur; for (0 => int i; i < e.numSubdivisions; i++) { 1 => m.noteOn; if (i < e.numSubdivisions - 1) { //don't need to do this after we play the last subdivision, since we can //go back to waiting for the event. //In fact, this will break if we wait for both mySubdivisionDur and e //after the last subdivision, since they will occur simultaneously, and //we will actually miss e being broadcast. mySubdivisionDur => now; } } } } fun void player2() { Mandolin m => dac; 500 => m.freq; while (true) { e => now; 1 => m.noteOn; } }