{
   "is_private" : null,
   "id" : "1-4Ro",
   "code" : "//Confetti 2, Xenakis-variant\r\n\r\nServer.default.boot;\r\n(\r\n~red=0; \r\n~green=1;\r\n~maxValue=32;  //change maxValue to 255 for the complete experience\r\n\r\n(\r\n/*There is a decreasing linear connection between log(freq) and value.\r\nlog(freq)=log(maxfreq)-((log(maxfreq)-log(minfreq))*value/maxValue), so\r\nfreq=exp(log(maxfreq)-((log(maxfreq)-log(minfreq))*value/maxValue))*/\r\n\r\nSynthDef(\\beeper, { arg value=150, pan=0;\r\n\tvar maxfreq=10000, minfreq=50;\r\n\tOut.ar(0, Pan2.ar(SinOsc.ar(exp(log(maxfreq)-((log(maxfreq)-log(minfreq))*value/~maxValue)), 0, 0.01), pan, 1));\r\n}).send(s);\r\n);\r\n)\r\n(\r\n~maxIndex=10;\r\nz=40;\r\n\r\nw=Window(\"Confetti2X\", Rect(400, 300, z*~maxIndex, z*~maxIndex)).front;\r\nw.view.background_(Color.white);\r\nw.front;\r\n\r\n//function for drawing array on screen\r\n\r\n\tw.drawHook = {\r\n\t\tfor(0, ~maxIndex-1, { arg v;\r\n\t\t\tfor(0, ~maxIndex-1, {arg h;\r\n\t\t\t\t~red=~tabel[v,h]/~maxValue;\r\n\t\t\t\t~green=1-(~tabel[v,h]/~maxValue);\r\n\t\t\t\tr = Rect(h*z+10, v*z, z,z); \t\t\t\t\tPen.color=Color(~red, ~green, 0);\r\n\t\t\t\t\tPen.addRect(Rect(h*z, v*z, z, z));\r\n\t\t\t\t\tPen.fill;\r\n\t\t\t\t(~tabel[v,h]+32).asAscii.asString.drawInRect(r, Font(\"Times\", 24));\r\n\t\t\t\t\t//remove \"+32\" when maxValue > 222, this may initially cause a blank window\r\n\t\t\t});\r\n\t\t});\r\n\t};\r\n\r\n\r\n//initialize array and put on screen\r\n(\r\nRoutine{\r\n~tabel=Array2D(~maxIndex, ~maxIndex);\r\nfor(0, ~maxIndex-1, { arg v;\r\n\tfor(0, ~maxIndex-1, {arg h;\t\r\n\t\t~tabel.put(v, h,0);\r\n\t});\t\t\r\n});\r\n{w.refresh}.defer;\r\n}.play;);\r\n//Initialize synths\r\n(\r\nRoutine{\r\n~syntabel=Array2D(~maxIndex, ~maxIndex);\r\nfor(0, ~maxIndex-1, { arg v;\r\n\tfor(0, ~maxIndex-1, {arg h;\t\r\n\t\t~syntabel.put(v, h,Synth(\\beeper, [\\value, 0, \\pan, (2*h/~maxIndex)-1])); //pan corresponds with horizontal position in array\r\n\t});\t\t\r\n});\r\n}.play;\r\n);\r\n\r\nRoutine({\r\n\tv= ~maxIndex.rand;\r\n\th= ~maxIndex.rand;\r\n\twhile ({~tabel.at(v,h) <= ~maxValue}, {\r\n\t\t~tabel.put(v, h, ~tabel.at(v, h) + 1);\r\n\t\t~syntabel[v,h].set(\\value, ~tabel.at(v,h));\r\n\t\t{w.refresh}.defer;\r\n\t\tv= ~maxIndex.rand;\r\n\t\th= ~maxIndex.rand;\r\n\t\t0.125.wait\r\n\t});\r\n\t10.wait;\r\n\tfor(0, ~maxIndex-1, { arg v;\r\n\t\tfor(0, ~maxIndex-1, {arg h;\t\r\n\t\t\t~syntabel[v,h].free;\r\n\t\t});\r\n\t});\r\n}).play;\r\n\t\r\n)",
   "labels" : [
      "distribution",
      "xenakis"
   ],
   "description" : "As Confetti2: http://sccode.org/1-31X in which you heard only one oscillator at the time. In SuperCollider it is easy to use 100 oscillators at the same time, so while a distribution is made, you can hear sounds that correspond with all the values in the box. That doesn't swing at all, instead it gives a kind of Xenakis-like experience.",
   "ancestor_list" : [],
   "name" : "Confetti2X",
   "author" : "henk.lasschuit"
}
