// title: Feigenbaum // author: henklass // description: // Moaning and groaning SuperCollider draws Feigenbaum's bifurcation graph... // This project was inspired by this video: https://www.youtube.com/watch?v=ETrYE4MdoLQ // There is a connection to the Mandelbrot set, which is implicitly explained in this video: https://www.youtube.com/watch?v=9gk_8mQuerg // code: /* This project was inspired by this video: https://www.youtube.com/watch?v=ETrYE4MdoLQ There is a connection to the Mandelbrot set, which is implicitly explained in this video: https://www.youtube.com/watch?v=9gk_8mQuerg */ s.boot; ( SynthDef( \pitches, {|nr, panpos| Out.ar(0, Pan2.ar( SinOsc.ar( (36+(60*nr)).midicps, 0, 0.01, 0), //use midicps for a nice equal spreading of pitches panpos; ) ) }).add; ) ( var startx=0.5; var windowHeight=950, windowWidth=1600; //nice values for a 1920 x 1080 screen var p1, p2; var pitchArray=Array.newClear(100); //initialise synths for (0, 99, { arg i; pitchArray[i]=Synth(\pitches,[ \nr, 0, \panpos, -1+(2*i/100)] ); }); w=Window("Feigenbaum", Rect(160, 40, windowWidth, windowHeight)).front; u = UserView(w, w.view.bounds); u.background=Color.white; u.clearOnRefresh_(false); u.drawFunc={ Pen.fillColor = Color.black; Pen.addRect(Rect(p1, p2, 1, 1)); Pen.fill; }; r=Routine({ forBy(0, 4, 4/windowWidth, {arg l; //l (for lambda, the fertility) runs from 0 to 4 //varying windowWidth will also vary the time it takes to finish the program l.postln; x=startx; for(1, 200, {arg t; //calculations are iterated 200 times x=l*x*(1-x); pitchArray[t%100].set(\nr, x); //you hear only 100 results at a time to emphasize the final result p1=l*windowWidth/4; p2=windowHeight-(x*windowHeight)-1; {u.refresh}.defer; 0.0025.wait; }); }); 10.wait; for (0, 99, { arg i; pitchArray[i].free}) }); r.play; )