{
   "name" : "another livecoding rehearsal",
   "author" : "tedthetrumpet",
   "description" : "More rehearsals towards a sort of algorave gig I've been offered, tidied up a bit. One run of this here https://soundcloud.com/tedthetrumpet/lcode-04-gmsnprep-05",
   "ancestor_list" : [],
   "labels" : [
      "livecoding"
   ],
   "code" : "// setup\r\nPdef.all.clear;\r\nNdef.all.clear;\r\n(\r\nSynthDef(\\blip, { |out= 0, freq = 261.6255653006, nharm = 10, gate = 1, amp = 0.1|\r\n\tvar sig = Blip.ar(freq * ((-2..2)/500 + 1), nharm); // five channels, detuned\r\n\tvar env = EnvGen.kr(Env.adsr(), gate, doneAction:2);\r\n\tsig = sig * env;\r\n\tOut.ar(out, Splay.ar(sig) * amp)\r\n}).add\r\n)\r\n\r\n~hitzpath=\"/Users/jsimon/Music/SuperCollider Recordings/hitzamples/\"; // various drum samples\r\n~bufs = (~hitzpath ++ \"*.aiff\").pathMatch.collect({ |i|  Buffer.read(s, i)});\r\n(\r\nSynthDef(\\bf, {|out=0 buf=0 amp=0.1 freq=261.6255653006|\r\n\tvar sig = PlayBuf.ar(2, buf, BufRateScale.kr(buf) * freq/60.midicps, doneAction:2);\r\n\tOut.ar(out, sig * amp)\r\n}).add\r\n)\r\n\r\nt = TempoClock(140/60).permanent_(true);\r\n\r\n~mbus = Bus.audio(s, 2);\r\nNdef(\\m).put(0, { InFeedback.ar(~mbus, 2) }).fadeTime_(0.2).play; // actually never used!\r\n\r\n// go\r\n\r\nPbindef(\\b, \\instrument, \\blip)\r\n~mel = {-12.rand}!16\r\nPbindef(\\b, \\scale, Scale.hexMajor7)\r\nPbindef(\\b, \\degree, Pseq(~mel,inf))\r\nPbindef(\\b, \\dur, 1/4)\r\nPbindef(\\b, \\out, ~mbus).play(t, quant:4) // <-----------------\r\n~mel2 = {-12.rand}!32\r\nPbindef(\\b, \\degree, Pseq(~mel2,inf))\r\nPbindef(\\b, \\degree, Pseq([~mel, ~mel, ~mel2].flatten,inf))\r\n// need to do something with nharm\r\nPbindef(\\b, \\nharm, Prand((1..10), inf))\r\n// varying the rhythm using amp, also guarantee a downbeat\r\n~gr = ([1] ++ [{2.rand}!15]).flatten/10\r\nPbindef(\\b, \\amp, Pseq(~gr, inf))\r\n// yeah!\r\nPbindef(\\d, \\instrument, \\bf).play(t, quant: 4) // main out fine for now\r\nPbindef(\\s, \\buf, ~bufs.choose) // find a snarish sound\r\nPbindef(\\s, \\amp, Pseq([0,1]/10, inf))\r\nPbindef(\\s, \\instrument, \\bf).play(t, quant: 4)\r\nPbindef(\\s).stop // jam\r\nPbindef(\\d).stop\r\nPbindef(\\b).stop\r\n// revisit melody\r\n~mel = {-12.rand}!16\r\n~mel2 = {-12.rand}!32\r\nPbindef(\\b, \\degree, Pseq([~mel, ~mel, ~mel2].flatten,inf))\r\n\r\nt.sync(30/60, 30) // slowdown nb .sync is an extension\r\n\r\ns.record\r\ns.stopRecording\r\nthisProcess.platform.recordingsDir.openOS",
   "id" : "1-51J",
   "is_private" : null
}
