{
   "is_private" : null,
   "id" : "1-5eq",
   "code" : "/*\r\nThis project was inspired by this video: https://www.youtube.com/watch?v=ETrYE4MdoLQ\r\nThere is a connection to the Mandelbrot set, which is implicitly explained in this video: https://www.youtube.com/watch?v=9gk_8mQuerg\r\n*/\r\n\r\ns.boot;\r\n\r\n(\r\nSynthDef( \\pitches, {|nr, panpos|\r\n\t\tOut.ar(0,\r\n\t\tPan2.ar(\r\n\t\t\tSinOsc.ar(\t(36+(60*nr)).midicps, 0, 0.01, 0),  //use midicps for a nice equal spreading of pitches\r\n\t\t\tpanpos;\r\n\t\t)\r\n\r\n\t)\r\n}).add;\r\n)\r\n\r\n(\r\nvar startx=0.5;\r\nvar windowHeight=950, windowWidth=1600; //nice values for a 1920 x 1080 screen\r\nvar p1, p2;\r\n\r\nvar pitchArray=Array.newClear(100);\r\n\r\n\r\n//initialise synths\r\nfor (0, 99, { arg i;\r\n\tpitchArray[i]=Synth(\\pitches,[ \\nr, 0, \\panpos, -1+(2*i/100)] );\r\n});\r\n\r\n\r\nw=Window(\"Feigenbaum\", Rect(160, 40, windowWidth, windowHeight)).front;\r\nu = UserView(w, w.view.bounds);\r\nu.background=Color.white;\r\nu.clearOnRefresh_(false);\r\n\r\n\r\nu.drawFunc={\r\n\tPen.fillColor = Color.black;\r\n\tPen.addRect(Rect(p1, p2, 1, 1));\r\n\tPen.fill;\r\n};\r\n\r\nr=Routine({\r\n\tforBy(0, 4, 4/windowWidth, {arg l;  //l (for lambda, the fertility) runs from 0 to 4\r\n\t\t//varying windowWidth will also vary the time it takes to finish the program\r\n\t\tl.postln;\r\n\t\tx=startx;\r\n\t\tfor(1, 200, {arg t;  //calculations are iterated 200 times\r\n\t\t\tx=l*x*(1-x);\r\n\t\t\tpitchArray[t%100].set(\\nr, x); //you hear only 100 results at a time to emphasize the final result\r\n\t\t\tp1=l*windowWidth/4;\r\n\t\t\tp2=windowHeight-(x*windowHeight)-1;\r\n\t\t\t{u.refresh}.defer;\r\n\t\t\t0.0025.wait;\r\n\r\n\t\t});\r\n\t});\r\n\t10.wait;\r\n\r\n\tfor (0, 99, { arg i;\r\n\t\tpitchArray[i].free})\r\n\r\n});\r\n\r\nr.play;\r\n)",
   "labels" : [
      "math feigenbaum bifurcation"
   ],
   "ancestor_list" : [],
   "description" : "Moaning and groaning SuperCollider draws Feigenbaum's bifurcation graph...\r\nThis project was inspired by this video: https://www.youtube.com/watch?v=ETrYE4MdoLQ\r\nThere is a connection to the Mandelbrot set, which is implicitly explained in this video: https://www.youtube.com/watch?v=9gk_8mQuerg",
   "name" : "Feigenbaum",
   "author" : "henklass"
}
