{
   "labels" : [
      "mathematics",
      "research"
   ],
   "id" : "1-4Wb",
   "is_private" : null,
   "code" : "/*\r\nThe Fibonacci-sequence as controlsignal: melodies from Pisano Periods.\r\nBecause the sequence runs more or less exponentially, it seems best to assign the values to frequencies. \r\n*/\r\ns.boot;\r\nSynthDef( \\puls, {|freq=30, out|\r\n\t\tOut.ar(out,\r\n\t\t\tSinOsc.ar(freq, mul: 0.5*EnvGen.kr(Env.perc(0.01,0.75), doneAction: 2)),0)\r\n}).add;\r\n(\r\nm=3000; //max index, 5 minutes = 300 when dur=0.1\r\na=Array.newClear(m);//two arrays to store numbers from the Pisano Periods\r\nb=Array.newClear(m);\r\na.put(0,0); \r\na.put(1,1);\r\nd=2; //even divisor\r\ni=2; //index\r\nwhile ({i<m}, {\t\t//fill array a with numbers from the even Pisano Periods\r\n\ta.put(i, (a[i-2]+a[i-1])%d);\r\n\tif ((a[i]==1)&&(a[i-1]==0), {d=d+2});\r\n\ti=i+1;\r\n});\r\nd.postln;\r\n\r\nb.put(0,0); \r\nb.put(1,1);\r\nd=3; //odd divisor\r\ni=2; //index\r\nwhile ({i<m}, {\t\t//fill array b with numbers from the odd Pisano Periods\r\n\tb.put(i, (b[i-2]+b[i-1])%d);\r\n\tif ((b[i]==1)&&(b[i-1]==0), {d=d+2});\r\n\ti=i+1;\r\n});\r\nd.postln;\r\n)\r\n(\r\nPbind(\r\n\t\\instrument, \t\\puls,\r\n\t\\out, 0,\t\t//array a plays in left channel\r\n\t\\dur, \t0.1,\r\n\t\\freq, Pseq((1+a)*30)\t//steps of 30Hz\r\n\t).play;\r\n\r\nPbind(\r\n\t\\instrument, \t\\puls,\r\n\t\\out, 1,\t\t//array b plays in right channel\r\n\t\\dur, \t0.1,\r\n\t\\freq, Pseq((1+b)*30)\r\n\t).play;\r\n\t\r\n\r\n)",
   "name" : "Pisano Melodies",
   "author" : "henk.lasschuit",
   "ancestor_list" : [],
   "description" : "Pisano Periods are used to generate melodies"
}
