«Pisano Melodies» by henk.lasschuit

on 15 Apr'14 15:55 in mathematicsresearch

Pisano Periods are used to generate melodies

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
/*
The Fibonacci-sequence as controlsignal: melodies from Pisano Periods.
Because the sequence runs more or less exponentially, it seems best to assign the values to frequencies. 
*/
s.boot;
SynthDef( \puls, {|freq=30, out|
		Out.ar(out,
			SinOsc.ar(freq, mul: 0.5*EnvGen.kr(Env.perc(0.01,0.75), doneAction: 2)),0)
}).add;
(
m=3000; //max index, 5 minutes = 300 when dur=0.1
a=Array.newClear(m);//two arrays to store numbers from the Pisano Periods
b=Array.newClear(m);
a.put(0,0); 
a.put(1,1);
d=2; //even divisor
i=2; //index
while ({i<m}, {		//fill array a with numbers from the even Pisano Periods
	a.put(i, (a[i-2]+a[i-1])%d);
	if ((a[i]==1)&&(a[i-1]==0), {d=d+2});
	i=i+1;
});
d.postln;

b.put(0,0); 
b.put(1,1);
d=3; //odd divisor
i=2; //index
while ({i<m}, {		//fill array b with numbers from the odd Pisano Periods
	b.put(i, (b[i-2]+b[i-1])%d);
	if ((b[i]==1)&&(b[i-1]==0), {d=d+2});
	i=i+1;
});
d.postln;
)
(
Pbind(
	\instrument, 	\puls,
	\out, 0,		//array a plays in left channel
	\dur, 	0.1,
	\freq, Pseq((1+a)*30)	//steps of 30Hz
	).play;

Pbind(
	\instrument, 	\puls,
	\out, 1,		//array b plays in right channel
	\dur, 	0.1,
	\freq, Pseq((1+b)*30)
	).play;
	

)
raw 1227 chars (focus & ctrl+a+c to copy)
reception
comments