// title: example sequencing soundfiles // author: Fredrik Olofsson // description: // simple example showing how to play one soundfile after the other in a sequence. use as a template. // code: //playing soundfiles in sequence - one after the other s.boot; ( s.latency= 0.05; b.do{|x| x.free}; //free all previous buffers b= [ //edit paths - any number of files - make sure mono Buffer.read(s, "/Applications/SuperCollider344/sounds/samples/Screech-01.wav"), Buffer.read(s, "/Applications/SuperCollider344/sounds/samples/Screech-02.wav"), Buffer.read(s, "/Applications/SuperCollider344/sounds/samples/Screech-03.wav"), Buffer.read(s, "/Applications/SuperCollider344/sounds/samples/Screech-04.wav"), Buffer.read(s, "/Applications/SuperCollider344/sounds/samples/Screech-05.wav"), Buffer.read(s, "/Applications/SuperCollider344/sounds/samples/Screech-06.wav"), Buffer.read(s, "/Applications/SuperCollider344/sounds/samples/Screech-07.wav"), Buffer.read(s, "/Applications/SuperCollider344/sounds/samples/Screech-08.wav") ]; SynthDef(\sample, {|out= 0, buf, rate= 1| Out.ar(out, PlayBuf.ar(1, buf, rate, doneAction:2)!2); }).add; ) //test1 - single Synth(\sample, [\buf, b[0]]).register.onFree{"hello".postln};//should post when first soundfile done playing //test2 - looping through samples one after the other ( Routine({ var index= 0; var c= Condition.new; inf.do{ var a= Synth(\sample, [\buf, b[index], \rate, 1]).register; a.onFree{ ("playing index:"+index).postln; c.unhang; }; c.hang; index= index+1%b.size; //play in sequence //index= b.size.rand; //or play random }; }).play; )