{
   "is_private" : null,
   "id" : "1-55Y",
   "code" : "(\r\n// Code to produce this piece: https://frankchannel.bandcamp.com/track/fragment-vi\r\n// From this album: http://frankchannel.bandcamp.com/album/fragments\r\n// Which features SuperCollider on every track\r\n\r\nSynthDef(\\sine, {|freq=440, amp=0.1, gate=1, sustain=0.1|\r\n\tvar sig = Splay.ar(SinOsc.ar(freq*[2**(-15/1200), 1, 2**(15/1200)]/3*2));\r\n\tvar env = EnvGen.kr(Env.perc(1e-5,sustain*3),gate,amp,doneAction:2);\r\n\tOut.ar(0, (sig*env*4).softclip/4);\r\n}).add;\r\n\r\n// a counter\r\n~counter = {\r\n\targ n=4, palindrome=false;\r\n\tvar pat;\r\n\tif(palindrome,\r\n\t\t{pat = Pn(Pseq((1..n).mirror))},\r\n\t\t{pat = Pn(Pseq((1..n)))}\r\n\t);\r\n\tpat.asStream;\r\n};\r\n\r\n// an accumulator\r\n// 1 -> 1\r\n// 2 -> 1, 2\r\n// 3 -> 1, 2, 3\r\n// n -> 1, .., n\r\n~accumulate = {\r\n\targ x, palindrome=false;\r\n\tPn(\r\n\t\tPlazy({\r\n\t\t\tvar n = x.next();\r\n\t\t\tvar pat;\r\n\t\t\tif(palindrome,\r\n\t\t\t\t{pat = Pseq((1..n).mirror)},\r\n\t\t\t\t{pat = Pseq((1..n))}\r\n\t\t\t);\r\n\t\t\tpat;\r\n\t\t})\r\n\t).asStream;\r\n};\r\n\r\n// a repeater\r\n// 1 -> 1\r\n// 2 -> 2, 2\r\n// 3 -> 3, 3, 3\r\n// n -> n, .., n\r\n~repeat = {\r\n\targ x;\r\n\tPn(\r\n\t\tPlazy({\r\n\t\t\tvar n = x.next();\r\n\t\t\tvar pat = Pseq(n!n);\r\n\t\t\tpat;\r\n\t\t})\r\n\t).asStream;\r\n};\r\n\r\n// inject rests into a stream\r\n// x = 1, 2, 3, 1, 2, 3, ...\r\n// f(x) = 1, 2, 3, \\rest, 1, 2, 3, \\rest ...\r\nf = {|x, n=3|\r\n\tPn(\r\n\t\tPlazy({\r\n\t\t\tPseq(x.nextN(n)++\\rest);\r\n\t\t})\r\n\t).asStream;\r\n};\r\n\r\n// apply a function to a stream\r\ng = {|x, f|\r\n\tPn(\r\n\t\tPlazy({\r\n\t\t\tPseq([f.(x.next)]);\r\n\t\t})\r\n\t).asStream;\r\n};\r\n\r\na = Ptuple([\r\n\tg.(~repeat.(~counter.(8,true)), {|x| [0, 5, 7, 9, 12].wrapAt(x-1)})\r\n\t,f.(g.(~repeat.(~counter.(7)), {|x| [0, 5, 7, 9, 12].wrapAt(x-1)}, 3))\r\n]).asStream;\r\n\r\nb = Ptuple([\r\n\tg.(~accumulate.(~counter.(8,true)), {|x| [0, 4, 9, 12, 14].wrapAt(x-1)})\r\n\t,f.(g.(~accumulate.(~counter.(7)), {|x| [0, 4, 9, 12, 14].wrapAt(x-1)}, 3))\r\n]).asStream;\r\n\r\nPseq([\r\n\tPbind(\\instrument, \\sine, \\legato, 1, \\degree, Pfin(32, Pclump(3, a)-5), \\dur, 0.125, \\sustain, Pkey(\\dur)*8, \\strum, Pseq([0.125, 0.125/2], inf))\r\n\t,Pbind(\\instrument, \\sine, \\legato, 1, \\degree, Pfin(32, Pclump(3, b)-2), \\dur, 0.125, \\sustain, Pkey(\\dur)*8, \\strum, Pseq([0.125, 0.125/2], inf))\r\n\t,Pbind(\\instrument, \\sine, \\legato, 1, \\degree, Pfin(32, Pclump(3, a)+2), \\dur, 0.125, \\sustain, Pkey(\\dur)*8, \\strum, Pseq([0.125, 0.125/2], inf))\r\n\t,Pbind(\\instrument, \\sine, \\legato, 1, \\degree, Pfin(32, Pclump(3, b)+0), \\dur, 0.125, \\sustain, Pkey(\\dur)*8, \\strum, Pseq([0.125, 0.125/2], inf))\r\n],inf).play(quant:4);\r\n)",
   "labels" : [],
   "description" : "Code to produce this piece: https://frankchannel.bandcamp.com/track/fragment-vi\r\nFrom this album: http://frankchannel.bandcamp.com/album/fragments\r\nWhich features SuperCollider on every track",
   "ancestor_list" : [],
   "author" : "coreyker",
   "name" : "Fragment VI"
}
