‹ Fluid Simulator in SuperCollider Deleted Quarks ›

Failed Tweet

2014-10-07 23:36 supercollider

clean-up: #43

During today's clean-up-of-old-projects I got stuck shrinking an old piece of SuperCollider code down to under 140 characters (sctweet). The shortest I could get it down to was 165 characters. Still, I thought I'd post the results of my efforts here - both if someone has suggestions or if someone wants to study the process. It's the same code, just rewritten over and over to be shorter - using every trick I could think of.

Of course one could imagine other goals than briefness - better sounding or less CPU taxing are two (probably better and more) common goals when optimising code in this manner.

n=Pbind(\tempo,2.5,\freq,Pseq([Pseq([103.8],14),Pseq([82.4],14)],inf),\amp,Pseq([2,1,1,2,2,1,1]/2,inf),\dur, 0.5);Ptpar([0,n,5,Pmul(\dur,2,Pmul(\freq,2,n)),15,Pmul(\freq,3,n),30,Pmul(\freq,3.5,n),80,Pmul(\dur,3,Pmul(\freq,5.035, n)),140,Pmul(\dur,1,Pmul(\freq,8,n))]).play

n=Pbind(\tempo,2.5,f=\freq,Pseq([Pseq([103.8],14),Pseq([82.4],14)],inf),\amp,Pseq([2,1,1,2,2,1,1]/2,inf),d=\dur, 0.5);Ptpar([0,n,5,Pmul(d,2,Pmul(\freq,2,n)),15,Pmul(f,3,n),30,Pmul(f,3.5,n),80,Pmul(d,3,Pmul(f,5.035, n)),140,Pmul(d,1,Pmul(f,8,n))]).play

n=Pbind(\tempo,2.5,f=\freq,Pseq([Pseq([103.8],14),Pseq([82.4],14)],inf),\amp,Pseq([2,1,1,2,2,1,1]/2,inf),d=\dur, 0.5);Ptpar([0,n,5,Pmul(d,2,Pmul(f,2,n)),15,Pmul(f,3,n),30,Pmul(f,3.5,n),80,Pmul(d,3,Pmul(f,5.035, n)),140,Pmul(d,1,Pmul(f,8,n))]).play

n=Pbind(\tempo,2.5,f=\freq,Pseq([Pseq([103.8],14),Pseq([82.4],14)],inf),\amp,Pseq([2,1,1,2,2,1,1]/2,inf),d=\dur, 0.5);Ptpar([0,n,5,Pmul(d,2,Pmul(f,2,n)),15,Pmul(f,3,n),30,Pmul(f,3.5,n),80,Pmul(d,3,Pmul(f,5.035, n)),140,Pmul(f,8,n)]).play

Ptpar([0,n=Pbind(\tempo,2.5,f=\freq,Pstutter(14,Pseq([103.8,82.4],inf)),\amp,Pseq([2,1,1,2,2,1,1]/2,inf),d=\dur,0.5),5,Pmul(d,2,Pmul(f,2,n)),15,Pmul(f,3,n),30,Pmul(f,3.5,n),80,Pmul(d,3,Pmul(f,5.035,n)),140,Pmul(f,8,n)]).play

a={|a,b|Pmul(a,b,n)};Ptpar([0,n=Pbind(\tempo,2.5,f=\freq,Pstutter(14,Pseq([103.8,82.4],99)),\amp,Pseq([2,1,1,2,2,1,1]/2,inf),d=\dur,0.5),5,Pmul(d,2,a.(f,2)),15,a.(f,3),30,a.(f,3.5),80,Pmul(d,3,a.(f,5.035)),140,a.(f,8)]).play

a={|a,b|Pmul(a,b,n)};Ptpar([0,n=Pbind(\tempo,5,f=\freq,Pstutter(14,Pseq([103.8,82.4],99)),\amp,Pseq([2,1,1,2,2,1,1]/2,inf)),10,Pmul(d,2,a.(f,2)),30,a.(f,3),60,a.(f,3.5),160,Pmul(d,3,a.(f,5.035)),280,a.(f,8)]).play

a={|a,b|Pmul(a,b,n)};Ptpar([0,n=Pbind(\tempo,5,f=\freq,Pstutter(14,Pseq([103.8,82.4],99)),\amp,Pseq([2,1,1,2,2,1,1]/2,inf)),10,Pmul(d=\dur,2,a.(f,2)),30,a.(f,3),60,a.(f,3.5),160,Pmul(d,3,a.(f,5.035)),280,a.(f,8)]).play

a={|x|Pmul(f,x,n)};Ptpar([0,n=Pbind(\tempo,5,f=\freq,Pstutter(14,Pseq([103.8,82.4],99)),\amp,Pseq([2,1,1,2,2,1,1]/2,inf)),10,Pmul(d=\dur,2,a.(2)),30,a.(3),60,a.(3.5),160,Pmul(d,3,a.(5.035)),280,a.(8)]).play

a=Pmul(f,_,n);b={|y,x|Pmul(\dur,y,a.(x))};Ptpar([0,n=Pbind(\tempo,5,f=\freq,Pstutter(14,Pseq([103.8,82.4],99)),\amp,Pseq([2,1,1,2,2,1,1]/2,inf)),10,b.(2,2),30,a.(3),60,a.(3.5),160,b.(3,5.035),280,a.(8)]).play

TempoClock.tempo= 1 //need to reset default clock tempo

a=Pmul(f,_,n);b={|y,x|Pmul(d,y,a.(x))};Ptpar([0,n=Pbind(f=\freq,Pstutter(14,Pseq([103.8,82.4],99)),\amp,Pseq([2,1,1,2,2,1,1]/2,inf),d=\dur,0.2),2,b.(2,2),6,a.(3),12,a.(3.5),32,b.(3,5.035),56,a.(8)]).play

a=Pmul(f,_,n);Ptpar([0,n=Pbind(f=\freq,Pstutter(14,Pseq([103.8,82.4],99)),\amp,Pseq([2,1,1,2,2,1,1]/2,inf),d=\dur,0.2),2,Pmul(d,2,a.(2)),6,a.(3),12,a.(3.5),32,Pmul(d,3,a.(5.035)),56,a.(8)]).play

a=Pmul(f,_,n);Ptpar([0,n=Pbind(f=\freq,Pseq([103.8,82.4],99).stutter(14),\amp,Pseq([2,1,1,2,2,1,1]/2,99),d=\dur,0.2),2,Pmul(d,2,a.(2)),6,a.(3),12,a.(3.5),32,Pmul(d,3,a.(5.035)),56,a.(8)]).play

n={|x,y=1|Pbind(\freq,Pseq([103.8,82.4],99).stutter(14)*x,\amp,Pseq([2,1,1,2,2,1,1]/2,99),\dur,y/5)};Ptpar([0,n.(1),2,n.(2,2),6,n.(3),12,n.(3.5),32,n.(5.035,3),56,n.(8)]).play

n={|x,y=1|Pbind(\freq,Pseq([104,82.5] stutter:14,99)*x,\amp,Pseq([2,1,1,2,2,1,1]/2,99),\dur,y/5)};Ptpar([0,n.(1),2,n.(2,2),6,n.(3),12,n.(3.5),32,n.(5.035,3),56,n.(8)]).play

n={|x,y=1|Pbind(\freq,Pseq([104,82.5] stutter:14,99)*x,\amp,Pseq([2,1,1,2,2,1,1]/2,99),\dur,y/5)};Ptpar([0,n.(1),2,n.(2,2),6,n.(3),12,n.(3.5),32,n.(5.04,3),56,n.(8)]).play

a=[0,1,1,2,2,2,6,3,1,12,3.5,1,32,5.04,3,56,8,1];{|i|Pbind(\lag,a[b=i*3],\freq,Pseq([104,82.5] stutter:14,99)*a[b+1],\amp,Pseq([2,1,1,2,2,1,1]/2,99),\dur,a[b+2]/5).play}!6

[0,1,1,2,2,2,6,3,1,12,3.5,1,32,5.04,3,56,8,1].clump(3).do{|x|Pbind(\freq,Pseq([104,82.5] stutter:14,99)*x[1],\amp,Pseq([2,1,1,2,2,1,1]/2,99),\dur,x[2]/5,\lag,x[0]).play}

‹ Fluid Simulator in SuperCollider Deleted Quarks ›