«Feigenbaum» by henklass

on 01 Jan'21 17:19 in math feigenbaum bifurcation

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
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;
)
raw 1568 chars (focus & ctrl+a+c to copy)
reception
comments
playjazz8810 user 14 Jan'21 01:28

Thanks for sharing this. I can't get it to run with the Audio server turned on though. It runs fine without the audio server. When I turn the server on it says n-set Node 1067 not found

playjazz8810 user 14 Jan'21 02:24

I left the previous comment about not getting it to work but I've figured it out now and it is running fine. Thank you again for sharing your code.