{
   "description" : "this is a infinite generative song based on Eno's Music for Airports.\r\n\r\nI realize this could be split up into different SynthDef's and sequenced with Pbinds, but I do like having everything inside one function (so I opted to use Demands).\r\n\r\nyou can listen to 20 minutes of this here: https://infinitedigits.bandcamp.com/track/eno",
   "ancestor_list" : [],
   "name" : "music for airports inspired generative music",
   "author" : "infinite digits",
   "id" : "1-5fq",
   "is_private" : null,
   "code" : "(\r\n{\r\n\targ hz=440,amp=0.5;\r\n\tvar note=hz.cpsmidi;\r\n\tvar snd,snd2,intro;\r\n\t\r\n\t// these notes are directly from Eno's Music for Airports\r\n\t// each phrase is one line, and played through\r\n\tvar airports=[\r\n\t\t[5,7,4,2,0,12,7,5,7,4,2,0],\r\n\t\t[5,7,4,2,0,12,4,7,5,0],\r\n\t\t[-5,2,0,4,7,12,5,2,7,4,0,7,2,5,5,2,4,0],\r\n\t\t[7,7,2,4,4,4,2,0,7,0,0],\r\n\t];\r\n\t// these are some chords I made up that sound nice with it\r\n\tvar planes=[\r\n\t\t[0,4,7,12],\r\n\t\t[4,7,11,16],\r\n\t\t[-3,0,4,7],\r\n\t\t[-3,0,5,9],\r\n\t];\r\n\t\r\n\t// setup the note change variables\r\n\tvar seq,seqnote,notepulse,noterate;\r\n\tvar planeseq,planenotes,planeenv,planenotechange;\r\n\t// piano stuff\r\n\tvar noise, string, delaytime, lpf, noise_env,pianosnd,pianosnd2, damp_mul,pianohz,noise_hz;\r\n\tvar noise_attack=0.002, noise_decay=0.06,\r\n\ttune_up = 1.0005, tune_down = 0.9996, string_decay=6.0,\r\n\tlpf_ratio=2.0, lpf_rq = 4.0, hpf_hz = 40, damp=0, damp_time=0.1;\r\n\r\n\t// chord and note changes (random)\r\n\tplanenotechange=Dust.kr(1/30)+Impulse.kr(0);\r\n\tplaneenv=1-EnvGen.kr(Env.perc(3,10,0.9),planenotechange);\r\n\tplanenotes=Demand.kr(TDelay.kr(planenotechange,3),0,Dxrand(planes,inf));\r\n\tnotepulse=1;\r\n\tnoterate=TChoose.kr(Dust.kr(notepulse)+Impulse.kr(0),[0.02,0.05,1,2,0.5,0.25,2]/2)*Rand(0.78,1.32);\r\n\tnotepulse=Impulse.kr(noterate);\r\n\tseq=Demand.kr(Dust.kr(0.1)+Impulse.kr(0),0,Dxrand(airports,inf));\r\n\tseqnote=Demand.kr(notepulse,0,Dseq(seq,inf));\r\n\t// bass note\r\n\tsnd=SinOsc.ar((note-24).midicps,mul:SinOsc.kr(Rand(0.001,0.01)).range(0.05,0.15));\r\n\tsnd=snd+SinOsc.ar((note-12).midicps,mul:SinOsc.kr(Rand(0.001,0.01)).range(0.001,0.05));\r\n\t// chords\r\n\tsnd=snd+(planeenv*Mix.ar(Array.fill(8,{arg i;\r\n\t\tvar snd;\r\n\t\tsnd=SawDPW.ar((note+planenotes[i%4]+Select.kr(DC.kr(i%4)<1,[24.neg,36.neg])).midicps,mul:0.9);\r\n\t\tsnd=LPF.ar(snd,LinExp.kr(SinOsc.kr(rrand(1/30,1/10),rrand(0,2*pi)),-1,1,hz,hz*5));\r\n\t\tsnd=DelayC.ar(snd, rrand(0.01,0.03), LFNoise1.kr(Rand(5,10),0.01,0.02)/15 );\r\n\t\tPan2.ar(snd,VarLag.kr(LFNoise0.kr(1/3),3,warp:\\sine))/7\r\n\t})));\r\n\tsnd=MoogLadder.ar(snd.tanh,LinExp.kr(VarLag.kr(LFNoise0.kr(1/6),6,warp:\\sine),-1,1,hz*2,hz*60));\r\n\tsnd=snd+(0.55*DynKlank.ar(`[[(note+planenotes[0]).midicps, (note+planenotes[1]).midicps, (note+planenotes[2]).midicps, (note+planenotes[3]).midicps], nil, [1, 1, 1, 1]], PinkNoise.ar([0.004, 0.004])));\r\n\r\n\t// piano sound from https://github.com/catfact/zebra/blob/master/lib/Engine_DreadMoon.sc#L20-L41\r\n\tnoise_hz=VarLag.kr(LFNoise0.kr(1/10),10).range(2000,5000);\r\n\tpianohz=A2K.kr((note+seqnote-12).midicps);\r\n\tnoise_env = Decay2.ar(Impulse.ar(noterate));\r\n\tnoise = LFNoise2.ar(noise_hz) * noise_env;\r\n\tdamp_mul = LagUD.ar(K2A.ar(1.0 - damp), 0, damp_time);\r\n\tdelaytime = 1.0 / (pianohz * [tune_up, tune_down]);\r\n\tstring = Mix.new(CombL.ar(noise, delaytime, delaytime, string_decay * damp_mul));\r\n\tpianosnd = RLPF.ar(string, lpf_ratio * pianohz, lpf_rq) * amp;\r\n\tpianosnd = HPF.ar(pianosnd, hpf_hz);\r\n\t\r\n\t// polyperc sound\r\n\tpianosnd2=(\r\n\t\tEnvGen.ar(Env.perc(release:4),notepulse)*\r\n\t\tMoogFF.ar(Pulse.ar((note+seqnote).midicps,mul:1.0),(note).midicps*1.5)\r\n\t);\r\n\t\r\n\t// mix between polyperc and piano sound randomly\r\n\tsnd=snd+SelectX.ar(SinOsc.kr(LFNoise0.kr(0.1).range(0.01,0.1)).range(0.1,0.9),[pianosnd*0.3,pianosnd2]);\r\n\tsnd=LPF.ar(snd,(note+36).midicps);\r\n\tsnd=HPF.ar(snd,120);\r\n\tsnd=snd*EnvGen.ar(Env.new([0,0,1],[0.5,3]));\r\n\tsnd=FreeVerb.ar(snd,0.45,2.0,0.5);\r\n\tsnd2=snd;\r\n\r\n\t// reverb \r\n\tsnd2 = DelayN.ar(snd2, 0.03, 0.03);\r\n\tsnd2 = CombN.ar(snd2, 0.1, {Rand(0.01,0.099)}!32, 4);\r\n\tsnd2 = SplayAz.ar(2, snd2);\r\n\tsnd2 = LPF.ar(snd2, 1500);\r\n\t5.do{snd2 = AllpassN.ar(snd2, 0.1, {Rand(0.01,0.099)}!2, 3)};\r\n\t\r\n\t// final output\r\n\tOut.ar(0,(snd2*0.1+snd)*amp);\r\n}.play;\r\n)",
   "labels" : [
      "ambient",
      "drone",
      "piano",
      "eno"
   ]
}
