Trying to understand this example by Nick Collins

Hi everyone

I am working through Nick Collins’s composerprogrammer tutorial.

I would like to understand better what is going on in this example:

SynthDef(\acsound,{|freq=440,amp=0.1,dur= 0.2,cutoff=2000|

var sound, filter;
sound=, amp)*[0,1,1,0],[0.01,0.05,(dur.max(0.07))-0.06]),doneAction:2);  


var currentvalue= 1.0.rand; 
var logisticmap, r;
logisticmap= {|previous=60|
			currentvalue = logisticmap.(currentvalue);
			//must convert from the value in the range 0.0 to 1.0 to a musically useful pitch value
			//quartertones here
			Synth(\acsound,[\freq, (60+((currentvalue*12).round(0.5))).midicps]); 

According to postln “logisticmap” produces values between 0.0 and 1.0.
I don’t quite understand why this works.
If for exmaple I evaluate “370.(1.0.rand)” supercollider just returns “370” and not something mapped between 0.0 and 1.0.
Or would this rather correspond to “370@(1.0.rand)” and one would write this differently for variables and plain numbers?

I am not really sure whether it is of any importance that “previous” is initialised at 60.
To me the sound always seems to linger in the same scope, no matter which number is associated with “previous”.

When I run this code:
The curve always looks the same no matter what number is used for “i”, but maybe here I am already on the wrong track.

Thanks a lot for explaining me this very basic thing about how the values from “logisticmap” are produced.

That’s correct.

logisticmap is a function. logisticmap.(something) is a shortcut syntax for logisticmap.value(something), which is the way to call the function.

370.(something) replaces the function with a constant value. This completely changes the meaning of the statement, so quite naturally, you wouldn’t expect to get the same result.

If you want to experiment with the result of the logisticmap function, then you have to invoke the actual function, not some unrelated number.

That is shortcut syntax to create a Point object, not related to this subject.

This isn’t exactly “initialization.” 60 is a default value. It will be used only when the function is called without supplying a value for it in the .value(...) argument list. The code example always provides an argument value – so 60 is never used and thus irrelevant.

Same confusion. 60 will be used only if your function is called without an argument value. But Array.fill always calls the function with a value (increasing series 0, 1 … n-1). So this default is always overridden, thus ignored.


Thanks a lot for clarification!

Sorry if I’m stating the obvious here, but perhaps it’s interesting to note that logistic map is one of the simplest equations that - for suitable parameter values - produces “chaos”.

see e.g.

Cool, thanks!
Enjoyed the video!