{
   "ancestor_list" : [],
   "description" : "just something i did as an excercise trying to understand clocks and scheduling",
   "name" : "sine(LFPar) minor random bliss in two",
   "author" : "Luka P.",
   "id" : "1-56a",
   "is_private" : null,
   "code" : "// two implementations of the same thing\r\n// first as a simple function scheduled on a TempoClock\r\n// second a Routine scheduled\r\n\r\n\r\n\r\n(\r\nt = { // this is just a function //\r\n\targ time;\r\n\tvar tone0, tone1, tone2, interval, freq0, next;\r\n\r\n\ttone0 = rrand(0,11);\r\n\tinterval = rrand(2,4);\r\n\tnext = rrand(1,4) / 6;\r\n\r\n\ttone1 = Scale.minor(\\pythagorean).at(tone0) + [0,12,24].choose + 0.07;\r\n\ttone2 = Scale.minor(\\pythagorean).at(tone0 + interval) + [0,12,24].choose;\r\n\tfreq0 = ((4*12) + [tone1,tone2] ).midicps;\r\n\r\n\tpostln(\"tone0\" + tone0 + \"| tone1:\" + tone1 + \"|tone2:\"\r\n\t\t+ tone2 + \"|interval:\" + interval + \"|nextime:\" + time);\r\n\r\n\t{ LFPar.ar(\tfreq: freq0,\r\n\t\t\tmul: EnvGen.kr(Env.perc(0, 3, 0.1),doneAction:2) ) }.play;\r\n\r\n\tnext.value; // schedule next event\r\n}\r\n)\r\n\r\n// start playing\r\nc = TempoClock.new.play(t);\r\n\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////////////\r\n// same thing converted into a Routine! :) \r\n(\r\nSynthDef(\"param\", { arg freq = #[300,310], sustain; // # - freq has literal array of defaults!\r\n\tvar sig;\r\n    sig = LFPar.ar(freq: freq,\r\n        mul: EnvGen.kr(Env.perc(0, sustain, 0.5), doneAction:2));\r\n\tsig = Splay.ar(sig);\r\n\tOut.ar(0, sig);\r\n}).add;\r\n\r\nr = Routine({\r\n\tvar tone0, tone1, tone2, interval, freq0, delta;\r\n\tloop {\r\n\t\t\r\n\t\ttone0 = rrand(0,11);\r\n\t\tinterval = rrand(2,4);\r\n\r\n\t\ttone1 = Scale.minor(\\pythagorean).at(tone0) + [0,12,24].choose + 0.07;\r\n\t\ttone2 = Scale.minor(\\pythagorean).at(tone0 + interval) + [0,12,24].choose;\r\n\t\tfreq0 = ((4*12) + [tone1,tone2] ).midicps;\r\n\r\n\t\tpostln(freq0);\r\n\r\n\t\tdelta = rrand(1,4) / 6;\r\n\t\tSynth(\"param\", [freq: freq0, sustain: delta * 8] );\r\n\t\tdelta.yield;\r\n\t}\r\n})\r\n)\r\n\r\n// start playing\r\nr.play;",
   "labels" : [
      "ambient",
      "random",
      "generative",
      "chill",
      "easy",
      "smooth",
      "minor"
   ]
}
