[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] recursion



Welcome Jonah, 

In case of interest to see a sounding implementation, since I like that conjecture, an example adapted from my live coding performances below. 

Best
N
 



//run me first
(
SynthDef(\threexplusone, {
	arg out=0, freq=440, amp=0.1;

	Out.ar(out,

		Pan2.ar(
			EnvGen.ar(Env([0,0.5,1.0,0.5,0.0],[0.01,0.001,0.2,0.5 ]),doneAction:2)
			*
			Resonz.ar(Mix(Saw.ar(freq:freq*[0.5,1,2.3], mul:amp))*0.3,Rand(4000,5000),XLine.kr(1.0,0.1,0.1),5)
			,0.0)
	)
}).add;
)


//now me
(

~func3xplus1 = {|x| if(x.even,x.div(2),3*x+1)};

//~func3xplus1.(3)

~threexplusoneroot = 48.midicps;

~seq = Pseq([1.0,0.5,0.25,0.5],inf).asStream;

~tempoclock = TempoClock(2);

~rhythm = 0.25;

Tdef(\threexplus1tdef,{

				inf.do({

					var x = rrand(1,700);
					var num = rrand(8,32);

					num.do{|ioi,i|

						var pitchnow = x;

						Synth(\threexplusone, [\freq, (~threexplusoneroot+pitchnow).min(6000), \amp, exprand(0.5,0.8), \extra, (x.min(100)*0.03).max(1)]);

						x = ~func3xplus1.(x);

						//[seq.next,0.25].choose.wait;
						~rhythm.value.wait;

					};
				})
}).play(~tempoclock);

)


//now tweak
~tempoclock.tempo = 1

~rhythm = {~seq.next};

~rhythm = {~func3xplus1.(rrand(1,16))*0.005};

~threexplusoneroot = 24.midicps;

//hack synth def, etc





> On 29 Dec 2019, at 16:09, rohrhuber@xxxxxxxxxxxxxx wrote:
> 
> ha! Now it’s time to add it here:
> 
> http://rosettacode.org/wiki/Hailstone_sequence
> 
>> On 29. Dec 2019, at 16:13, daniel-mayer@xxxxxxxx wrote:
>> 
>> 
>> ... but to be consequent: also col isn't needed anymore ...
>> 
>> 
>> ~collatz_R = { |n, l = 1000|
>>   n != 1 and: { l > 0 } if: {
>>       ~collatz_R valueArray: [n.even.if { n div: 2 } { n * 3 + 1 }, l - 1]
>>   } add: n
>> }
>> 
>> Greetings
>> 
>> Daniel
>> 
>> -----------------------------
>> http://daniel-mayer.at
>> -----------------------------
>> 
>> 
>> _______________________________________________
>> sc-users mailing list
>> 
>> info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
>> archive: https://listarc.bham.ac.uk/marchives/sc-users/
>> search: https://listarc.bham.ac.uk/lists/sc-users/search/
> 
> 
> 
> _______________________________________________
> sc-users mailing list
> 
> info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
> archive: https://listarc.bham.ac.uk/marchives/sc-users/
> search: https://listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/