/* define a single "clip" which is a sequence of string plucks it prints when it begins and reports how long it will exist the program runs in real time starting the clip at TIME 0 and ends when it has nothing left to do command line: chuck clip.ck */ // define the "clip" as a function fun void clip(dur myDur) { StifKarp myString => dac; // wire up the output of a string physical model to the DAC <<<"\tclip start at",now/second,"seconds">>>; now => time myBeg; myBeg + myDur => time myEnd; while (now < myEnd) { myString.pluck(0.5); 500::ms => now; } <<<"\tclip end at",now/second,"seconds">>>; } // TIME 0, start the clip spork ~clip(5::second); // launch clip in independent shred 5::second => now; // this master shred needs to remain alive while it's playing me.yield(); // on this exact sample, yield master shred so sporked one can finish first // last item in this program is this print statement <<<"program end at",now/second,"seconds">>>; // and with nothing left to do this program exits