{
   "code" : "//playing soundfiles in sequence - one after the other\r\ns.boot;\r\n\r\n(\r\ns.latency= 0.05;\r\nb.do{|x| x.free};\t//free all previous buffers\r\nb= [\t//edit paths - any number of files - make sure mono\r\n\tBuffer.read(s, \"/Applications/SuperCollider344/sounds/samples/Screech-01.wav\"),\r\n\tBuffer.read(s, \"/Applications/SuperCollider344/sounds/samples/Screech-02.wav\"),\r\n\tBuffer.read(s, \"/Applications/SuperCollider344/sounds/samples/Screech-03.wav\"),\r\n\tBuffer.read(s, \"/Applications/SuperCollider344/sounds/samples/Screech-04.wav\"),\r\n\tBuffer.read(s, \"/Applications/SuperCollider344/sounds/samples/Screech-05.wav\"),\r\n\tBuffer.read(s, \"/Applications/SuperCollider344/sounds/samples/Screech-06.wav\"),\r\n\tBuffer.read(s, \"/Applications/SuperCollider344/sounds/samples/Screech-07.wav\"),\r\n\tBuffer.read(s, \"/Applications/SuperCollider344/sounds/samples/Screech-08.wav\")\r\n];\r\nSynthDef(\\sample, {|out= 0, buf, rate= 1|\r\n\tOut.ar(out, PlayBuf.ar(1, buf, rate, doneAction:2)!2);\r\n}).add;\r\n)\r\n\r\n\r\n//test1 - single\r\nSynth(\\sample, [\\buf, b[0]]).register.onFree{\"hello\".postln};//should post when first soundfile done playing\r\n\r\n\r\n//test2 - looping through samples one after the other\r\n(\r\nRoutine({\r\n\tvar index= 0;\r\n\tvar c= Condition.new;\r\n\tinf.do{\r\n\t\tvar a= Synth(\\sample, [\\buf, b[index], \\rate, 1]).register;\r\n\t\ta.onFree{\r\n\t\t\t(\"playing index:\"+index).postln;\r\n\t\t\tc.unhang;\r\n\t\t};\r\n\t\tc.hang;\r\n\t\tindex= index+1%b.size;\t//play in sequence\r\n\t\t//index= b.size.rand;\t//or play random\r\n\t};\r\n}).play;\r\n)",
   "is_private" : null,
   "id" : "1-4TI",
   "labels" : [],
   "description" : "simple example showing how to play one soundfile after the other in a sequence.  use as a template.",
   "ancestor_list" : [],
   "author" : "Fredrik Olofsson",
   "name" : "example sequencing soundfiles"
}
