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= Saw.ar(freq, amp)*EnvGen.kr(Env([0,1,1,0],[0.01,0.05,(dur.max(0.07))-0.06]),doneAction:2);
filter= LPF.ar(sound,Line.kr(cutoff,300,dur));
Out.ar(0,filter.dup(2))
}).add;
)
(
var currentvalue= 1.0.rand;
var logisticmap, r;
r=3.74;
logisticmap= {|previous=60|
((1.0-previous)*previous*r).postln;
};
{
50.do{
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]);
0.125.wait;
};
}.fork;
)
http://composerprogrammer.com/teaching/supercollider/sctutorial/9.1%20Algorithmic%20Strategies.html
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:
Array.fill(50,{|i=60|((1.0-i)i3.74)}).plot
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.