pact - februari

another 30days of daily experiments. this time with cairo 2d and cinder + supercollider for sound. one very simple sketch per day to learn.

update 120212: i ported them all to processing. see _here
update 120617: rendered 1min mp3 excerpts. attached below under the code snippets.

 

//--pakt29
osx binary
c++ code
processing

Ndef(\wrap).play
(
Ndef(\wrap, {var n= 29; Splay.ar({|i|
        var w= i+LFSaw.ar(i+1*SinOsc.ar(0.1, i/n*2pi, 1, 0.1), 0, 2, 2);
        Saw.ar(340+LFSaw.ar(0.1, i/n, 10, 10).round(20)+i)%Saw.ar(60+w, SinOsc.ar(0.01, i/n*2pi, 2, 2.05))*0.25;
}!n)});
)
Ndef(\wrap).stop


 

//--pakt28
osx binary
c++ code
processing

Ndef(\round).play
(
Ndef(\round, {var n= 28; GVerb.ar(Limiter.ar(LeakDC.ar(Mix({|i|
        var z= SinOsc.ar(i.linexp(0, n-1, 70, 1500), LFSaw.ar(i+1*5, 0, 0.5pi), LFSaw.ar(0.2+SinOsc.ar(i+1*0.001, 0, 0.5), i/n, 0.4).max(0))*SinOsc.ar(200+i, 0, SinOsc.ar(0.03, i+1, 0.5, 1))*SinOsc.ar(400+i, 0, SinOsc.ar(0.04, i+2, 0.5, 1))*SinOsc.ar(800+i, 0, SinOsc.ar(0.05, i+3, 0.5, 1));
        Pan2.ar(z, i.linlin(0, n-1, -0.925, 0.925), 1/n);
}!n))), 3, 5, 0.2, 0.8, 20, 0.1)});
)
Ndef(\round).stop


 

//--pakt27
osx binary
c++ code
processing

Ndef(\sweep).play
(
Ndef(\sweep, {var n= 9; GVerb.ar(Mix({|i|
        var t= i/n;
        var t2pi= t*2pi;
        var f= 2**i*10+100;
        var z= LeakDC.ar(VarSaw.ar(SinOsc.ar(i+1*0.005, SinOsc.ar(i+1*SinOsc.ar(0.05, t2pi, 0.2, 0.4), 0, 2pi), f*SinOsc.ar(0.002, t2pi, 0.3, 0.5), f), t, SinOsc.ar(i+1*0.006, t2pi, 0.4, 0.5), i.linlin(0, n-1, 0.4, 0.1)));
        Pan2.ar(z, SinOsc.ar(0.015, t2pi, i.linlin(0, n-1, 0.99, 0.2)), 1/n);
}!n), 30, 5, 0.3, 0.8, 10)});
)
Ndef(\sweep).stop


 

//--pakt26
osx binary
c++ code
processing

Ndef(\grid).play
(
Ndef(\grid, {var n= 8; Mix({|i|
        var t= i/n;
        var z= LeakDC.ar(VarSaw.ar(SinOsc.ar(VarSaw.ar(i+1*VarSaw.ar(0.048, 0, 0.5, 25, 150), t, 1/3, 150), VarSaw.ar(100+i, t, VarSaw.ar(0.024, t, 0.25, 0.475, 0.5))*pi, VarSaw.ar(0.012, t, 0.75, VarSaw.ar(0.064, t, 0.5, 25, 50), 200), VarSaw.ar(0.16, t, 2/3, VarSaw.ar(0.02, t, 0.5, 7.5).abs, 300)), t));
        Pan2.ar(z, VarSaw.ar(0.02, t, 0.5), 1/n);
}!n)});
)
Ndef(\grid).stop


 

//--pakt25
osx binary
c++ code
processing

Ndef(\wobble).play
(
Ndef(\wobble, {var n= 5; Mix({|i|
        var z= SinOsc.ar(0, SinOsc.ar(60+(i*SinOsc.ar(0.004, 0, 0.8, 1)), i/n*2pi, SinOsc.ar(0, SinOsc.ar(1, 0, 2pi), SinOsc.ar(0.006), 2pi)), 1/n);
        Pan2.ar(z, z);
}!n)});
)
Ndef(\wobble).stop


 

//--pakt24
osx binary
c++ code
processing

Ndef(\swoop).play
(
Ndef(\swoop, {var n= 24; Mix({|i|
        var t= i/n;
        var f= SinOsc.ar(0.01, t*0.5pi).exprange(i*22+100, i*44+1000);
        var a= SinOsc.ar(0.05*t, t*2pi, 0.15).max(0);
        var z= RLPF.ar(GrayNoise.ar(a), f*(a+1), 1.4-a-t);
        Pan2.ar(z, LFTri.ar(0.05, t*4, 0.95));
}!n)});
)
Ndef(\swoop).stop


 

//--pakt23
osx binary
c++ code
processing

Ndef(\sway).play
(
Ndef(\sway, {var n= 23; LeakDC.ar(Splay.ar({|i|
        var t= i/n;
        var f= t.linexp(0, 1, LFTri.ar(0.04, t*4, 400, 600), LFTri.ar(0.03, t*4, 400, 600));
        var a= SinOsc.ar(SinOsc.ar(0.02, t*pi, 0.5), 0, 0.5).max(0);
        SinOsc.ar(f+SinOsc.ar(f, 0, f*a), LFTri.ar(SinOsc.ar(t+0.01, t, 20), t*4, 4pi), a)
       
}!n))});
)
Ndef(\sway).stop


 

//--pakt22
osx binary
c++ code
processing

Ndef(\blob).play
(
Ndef(\blob, {var n= 33; Mix({|i|
        var t= i/n*2pi;
        Pan2.ar(
                LeakDC.ar(SinOsc.ar(Pulse.ar(0.0625, 2/3).range(0.0625, 0.125), SinOsc.ar(Pulse.ar(i+1, Pulse.ar(i+1*0.125, 0.4, 1/3, 0.5), i+1*n, i+1*n*2), t, SinOsc.ar(SinOsc.ar(0.0625, t), t, 2pi)), SinOsc.ar(i+1*0.125, t, i.linexp(0, n-1, 3/n, 0.001)))),
                SinOsc.ar(0.125, t, i.linlin(0, n-1, 0, 0.95))
        )
}!n)});
)
Ndef(\blob).stop


 

//--pakt21
osx binary
c++ code
processing

Ndef(\flush).play
(
Ndef(\flush, {var a= {|i| 2.pow(i)}!7; Mix(
        Pan2.ar(
                Resonz.ar(SinOsc.ar(0, GrayNoise.ar(a*30*pi), 0.5), a*300, SinOsc.ar(a*0.13, 0, 0.4, 0.5)),
                SinOsc.ar(a*0.03, 0, 0.95)
        )
)});
)
Ndef(\flush).stop


 

//--pakt20
osx binary
c++ code
processing

Ndef(\veil).play
(
Ndef(\veil, {var n= 15; GVerb.ar(Mix({|i|
        var t= i/n*2pi;
        var f= SinOsc.ar(SinOsc.ar(i*0.015+0.015, t), t);
        var a= SinOsc.ar(f*SinOsc.ar(i*0.15+0.15, t, 0.15, 0.3), t, 150, 300);
        var b= SinOsc.ar(f*SinOsc.ar(i*0.15+0.15, t, 0.15, 0.5), t, 1500, 3000);
        Pan2.ar(
                BPF.ar(
                        Saw.ar(SinOsc.ar(f, t).exprange(a, b), SinOsc.ar(f, t, SinOsc.ar(0.015*t+0.15, t, 0.15).max(0))),
                        a+b*0.5,
                        0.15
                ),
                i/(n-1)*2-1
        );
}!n), 15, 1.5, 0.15)});
)
Ndef(\veil).stop


 

//--pakt19
osx binary
c++ code
processing

Ndef(\bubbles).play
(
Ndef(\bubbles, {var n= 6;
        GVerb.ar(Mix({|i|
                var q= i/n*2pi;
                var t= Impulse.ar(SinOsc.ar(SinOsc.ar(0.125, q, 0.5), 0, 1.5, 2), i/n);
                Pan2.ar(
                        SinOsc.ar(
                                SinOsc.ar(0.01, q, SinOsc.ar(0.05, q, 50), 500),
                                Decay2.ar(t, 0.02, 0.2, SinOsc.ar(0.05, q, SinOsc.ar(0.01, 0, 8pi, 8pi))),
                                Decay2.ar(t, TRand.ar(0.003, 0.03, t), TRand.ar(0.05, 0.1, t), SinOsc.ar(0.08, q, 0.2, 0.05).max(0))
                        ),
                        (i/(n-1))*2-1
                );
        }!n), 40, 2, 0.6);
});
)
Ndef(\bubbles).stop


 

//--pakt18
osx binary
c++ code
processing

Ndef(\grey).play
(
Ndef(\grey, {Mix({|i|
        var t= Impulse.ar(SinOsc.ar(0.1+(i*0.125), i/10*2pi+#[0, 0.1], 4, SinOsc.ar(0.01+(i*0.01), 0, 4, 12)));
        Pan2.ar(
                FreeVerb.ar(
                        BPF.ar(
                                GrayNoise.ar(
                                        Decay2.ar(
                                                t,
                                                TRand.ar(0.005, 0.015, t),
                                                TRand.ar(0.1, 0.15, t),
                                                TRand.ar(0.35, 0.5, t)
                                        )
                                ),
                                SinOsc.ar(i+1*0.032, #[0, 0.1]+i).exprange(i+1*300, i+1*600),
                                SinOsc.ar(i+1*0.025, #[0, 0.1]+i).range(0.1, 1)
                        ),
                        0.3
                ),
                SinOsc.ar(0.1, #[0, 0.1]+i, 0.9)
        );
}!10)});
)
Ndef(\grey).stop


 

//--pakt17
osx binary
c++ code
processing

Ndef(\shades).play
(
Ndef(\shades, {Mix({|i|
        var x= SinOsc.ar(0, SinOsc.ar(0.01*i+0.03, i, 2pi));
        var y= SelectX.ar(x.range(0, 4), [WhiteNoise.ar, GrayNoise.ar, PinkNoise.ar, BrownNoise.ar]);
        var z= Pan2.ar(y, x*0.4);
        BPF.ar(Rotate2.ar(z[0], z[1], i/3*2-1), i+1*500, SinOsc.kr(0, SinOsc.ar(i*0.02+0.01, i, pi)).range(1, 10), 0.3);
}!4)});
)
Ndef(\shades).stop


 

//--pakt16
osx binary
c++ code
processing

Ndef(\wheel).play
(
Ndef(\wheel, {Splay.ar(BPF.ar(PinkNoise.ar(1!3)*SinOsc.ar(VarSaw.ar(#[0.011, 0.012, 0.013], #[0, 0.1, 0.2], 0.5, VarSaw.ar(#[0.01, 0.02, 0.03], #[0, 0.1, 0.2]).exprange(5, 50), #[300, 303, 309]), CombN.ar(Saw.ar(#[3, 2.5, 1], 0.5pi).sum, 0.05, 0.05), 3), VarSaw.ar(#[0.021, 0.022, 0.023], #[0.2, 0.1, 0.3]).exprange(500, 2000), VarSaw.ar(#[0.031, 0.032, 0.033], #[0, 0.1, 0.2]).exprange(0.06, 0.6)))});
)
Ndef(\wheel).stop


 

//--pakt15
osx binary
c++ code
processing

Ndef(\spin).play
(
Ndef(\spin, {GVerb.ar(Mix(Pan2.ar(Formlet.ar(LPF.ar(Saw.ar((5..1)*LFPulse.ar(SinOsc.ar(0.1, 0, 0.5, 1), 0.5, 0.5, 10, 50)+SinOsc.ar((6..2)*0.05).exprange(0.05, 50), 0.3), 300)+Impulse.ar((0..4)+SinOsc.ar((4..8)*0.02).exprange(0.3, 300)), (1..5)*SinOsc.ar((5..9)*0.05).exprange(200, 2000)*SinOsc.ar(SinOsc.ar((2..6)*0.1, 0, 0.1), 0, 0.1, 1), 0.001, 0.0015), SinOsc.ar(SinOsc.ar((3..7)*0.1, 0, 0.1)))))});
)
Ndef(\spin).stop


 

//--pakt14
osx binary
c++ code
processing

Ndef(\interfere).play
(
Ndef(\interfere, {var a= #[3, 1, 5, 2]; Limiter.ar(Splay.ar(Formlet.ar(LFPulse.ar(a*100+SinOsc.ar(a, 0, a/20), 0, SinOsc.ar(a/10, 0, 0.45, 0.5), LFPulse.ar(a+a, 0, SinOsc.ar(a/10, 0, 0.45, 0.5), 0.1)), a*100+LFPulse.ar(a/2, 0, 0.5, a*SinOsc.ar(a/100, 0, 150, 200)), SinOsc.ar(a/30, 0, 0.01, 0.0125), SinOsc.ar(a/60, 0, 0.05, 0.055), 0.2)))});
)
Ndef(\interfere).stop


 

//--pakt13
osx binary
c++ code
processing

Ndef(\pulse).play
(
Ndef(\pulse, {GVerb.ar(Splay.ar(Resonz.ar(LFPulse.ar(#[121, 232, 343]), LFPulse.ar(#[0.121, 0.232, 0.343]).exprange(LFPulse.ar(#[12.1, 23.2, 34.3]).range(80, 100), LFPulse.ar(#[1.21, 2.32, 3.43].reverse).range(800, 1000)).sum*LFPulse.ar(#[0.121, 0.232, 0.343]).range(0.5, 1), 0.3, 0.15)), 34, 3, 0.2)});
)
Ndef(\pulse).stop


 

//--pakt12
osx binary
c++ code
processing

Ndef(\waves).play
(
Ndef(\waves, {var n= 3; Mix({|i|
        var z= VarSaw.ar(i+1*0.01, 0, 0.5, 5, VarSaw.ar(i+1*10, 0, 0.5, 0.5, 10));
        var w= VarSaw.ar(i+1*VarSaw.ar(i+1*0.001, 0, 0.5, z, z*z), 0, 0.5, 0.5, 0.5);
        Pan2.ar(
                SinOsc.ar(0, VarSaw.ar(i+1*w*100, 0, w, 2pi), VarSaw.ar(i+1*w*0.1, 0, w, 0.5)),
                i.linlin(0, n-1, -0.9, 0.9),
                2/n
        )
}!n)});
)
Ndef(\waves).stop


 

//--pakt11
osx binary
c++ code
processing

Ndef(\hail).play
(
Ndef(\hail, {Splay.ar(Ringz.ar(SinOsc.ar(#[0.000101, 0.000202, 0.000303, 0.000404, 0.000505, 0.000606], SinOsc.ar(#[101, 202, 303, 404, 505, 606], 0, SinOsc.ar(#[0.0101, 0.0202, 0.0303, 0.0404, 0.0505, 0.0606], 0, pi)))*VarSaw.ar(#[1.01, 2.02, 3.03, 4.04, 5.05, 6.06], #[0.101, 0.202, 0.303, 0.404, 0.505, 0.606], SinOsc.ar(#[0.00101, 0.00202, 0.00303, 0.00404, 0.00505, 0.00606], 0, 0.5, 0.5)), #[1010, 2020, 3030, 4040, 5050, 6060], SinOsc.ar(#[10.1, 20.2, 30.3, 40.4, 50.5, 60.6], 0, 0.1, 0.2), 0.2))});
)
Ndef(\hail).stop


 

//--pakt10
osx binary
c++ code
processing

Ndef(\rain).play
(
Ndef(\rain, {
        var n= 30;
        Mix({|i|
                var z= SinOsc.ar(i+1*0.01, 0, 0.001);
                var f= i*100+100+SinOsc.ar(0.0123+z, i/n*2pi).exprange(1, 30);
                var q= SinOsc.ar(0.0234+z, i/n*2pi, 0.3, 0.7);
                var p= SinOsc.ar(0.0345+z, i/n*2pi);
                var a= SinOsc.ar(0.0456+z, i/n*2pi, 0.4, 0.45);
                var x= HPF.ar(BPF.ar(HPF.ar(ClipNoise.ar(2)*Crackle.ar(SinOsc.ar(0.0123+z, i/n*2pi, 0.1, 1.8))), f, q));
                Pan2.ar(x, p, a);
        }.dup(n));
});
)
Ndef(\rain).stop


 

//--pakt09
osx binary
c++ code
processing

Ndef(\snow).play
(
Ndef(\snow, {
        Mix({|i|
                var m= SinOsc.ar(0.005, i/5*2pi, 2pi);
                var p= WhiteNoise.ar(SinOsc.ar(i*5000+5000)*SinOsc.ar(i*500+500)*SinOsc.ar(i*50+50)*SinOsc.ar(i*5+5));
                Pan2.ar(SinOsc.ar(p, p*m, p), p, 0.5);
        }.dup(5));
});
)
Ndef(\snow).stop


 

//--pakt08
osx binary
c++ code
processing

Ndef(\redqueen3).play
(
Ndef(\redqueen3, {GVerb.ar(LeakDC.ar(
        Saw.ar(
                Saw.ar([100, 101]+Saw.ar([102, 103], Saw.ar([4, 5], Saw.ar([1, 2], 6, 7).sum).sum).sum).exprange(Saw.ar(1/12, 4, 50), Saw.ar(1/8, 3, Saw.ar(1/16, 4, 65))),
                Saw.ar([21, 20], Saw.ar([40, 41], 0, 0.1), 0.2)
        )), 60, 4, 0.5, 0.5, 5, 0.5, 0.5, 0.75)});
)
Ndef(\redqueen3).stop


 

//--pakt07
osx binary
c++ code
processing

Ndef(\redqueen2).play
(
Ndef(\redqueen2, {GVerb.ar(LeakDC.ar(
        SinOsc.ar(
                SinOsc.ar(
                        SinOsc.ar(
                                SinOsc.ar(
                                        SinOsc.ar(
                                                SinOsc.ar(
                                                        SinOsc.ar(
                                                                1,
                                                                0,
                                                                2,
                                                                SinOsc.ar(1/2).exprange(1, 2)
                                                        ),
                                                        0,
                                                        8,
                                                        SinOsc.ar(1/4).exprange(4, 8)
                                                ),
                                                0,
                                                32,
                                                SinOsc.ar(1/8).exprange(16, 32)
                                        ),
                                        0,
                                        128,
                                        SinOsc.ar(1/16).exprange(64, 128)
                                ),
                                0,
                                512,
                                SinOsc.ar(1/32).exprange(256, 512)
                        ),
                        0,
                        2048,
                        SinOsc.ar(1/64).exprange(1024, 2048)
                ), 0, 0.1)
        ), 16, 8, 0.75, 0.5)});
)
Ndef(\redqueen2).stop


 

//--pakt06
osx binary
c++ code
processing

Ndef(\redqueen).play
(
Ndef(\redqueen, {GVerb.ar(LeakDC.ar(SinOsc.ar(SinOsc.ar([1/16, 1/12], 0, 5), SinOsc.ar(0, SinOsc.ar([SinOsc.ar(3, 0, 5, 12), SinOsc.ar(4, 0, 4, 16)], SinOsc.ar([SinOsc.ar(1/64, SinOsc.ar(0.5, 0, pi)).exprange(1, 30), SinOsc.ar(1/48, SinOsc.ar(0.75, 0, pi)).exprange(1, 30)], SinOsc.ar(SinOsc.ar(1/32, 0, 4), 0, 2pi), SinOsc.ar([1/6, 1/8], 0, 0.5pi, 2pi)), SinOsc.ar([1/3, 2/3], 0, 0.5pi, SinOsc.ar(1/8, 0, 0.5pi, 2pi))), SinOsc.ar([4/3, 3/4], 0, 0.5pi, SinOsc.ar([SinOsc.ar(1/256).exprange(80, 800), SinOsc.ar(1/256).exprange(80.8, 808)], 0, 0.5pi, 2pi)))))*0.05, 10, 3, 0.5, 0.5)});
)
Ndef(\redqueen).stop


 

//--pakt05
osx binary
c++ code
processing

Ndef(\noises).play
(
Ndef(\noises, {
        var freq= SinOsc.ar(SinOsc.ar((4..0)/150+SinOsc.ar((0..4)/18, 0, 0.8)), SinOsc.ar((0..4)/80+SinOsc.ar((0..4)/20, 0, 0.1), 0, 2pi)).exprange(100, 1000);
        var rq= SinOsc.ar(SinOsc.ar((0..4)/6+SinOsc.ar((0..4)/19, 0, 0.7), SinOsc.ar((4..0)/5+SinOsc.ar((4..0)/2, 0, 0.1), 0, 2pi))).exprange(0.4, 4);
        Splay.ar(BPF.ar(BPF.ar(ClipNoise.ar(1!5), freq, rq), freq, rq), 0.85);
});
)
Ndef(\noises).stop


 

//--pakt04
osx binary
c++ code
processing

Ndef(\lines).play
(
Ndef(\lines, {Splay.ar(LeakDC.ar(SinOsc.ar([0.033, 0.066, 0.055, 0.044], SinOsc.ar([0.12, 0.13, 0.11, 0.14]*SinOsc.ar([0.151, 0.152, 0.153, 0.154], SinOsc.ar([5, 4, 3, 2], 0, 2pi), SinOsc.ar([0.043, 0.053, 0.063, 0.073], 0, [80, 60, 40, 100])), SinOsc.ar(([60, 64, 67, 71]+SinOsc.ar([0.024, 0.025, 0.026, 0.027], SinOsc.ar([0.01, 0.02, 0.03, 0.04], 0, pi), 1).round).midicps, 0, 2pi)), 0.2)))})
)
Ndef(\lines).stop


 

//--pakt03
osx binary
c++ code
processing

Ndef(\varsaws).play
(
Ndef(\varsaws, {GVerb.ar(CombC.ar(VarSaw.ar(SinOsc.ar([0.1, 0.11], 0, 5, 100+SinOsc.ar([0.05, 0.055], 0, 50, 50).round(50)), 0, SinOsc.ar([0.2, 0.22], 0, 0.5, SinOsc.ar([0.3, 0.33], 0, 0.1, 0.5)), 0.1), 1.01, SinOsc.ar([0.4, 0.44], 0, 0.01, 1), 8), 80, 5, 0.9)})
)
Ndef(\varsaws).stop


 

//--pakt02
osx binary
c++ code
processing

Ndef(\saws).play
(
Ndef(\saws, {Splay.ar(BPF.ar(LeakDC.ar(Saw.ar(SinOsc.ar((0..5)+1*0.02, SinOsc.ar((0..5)+1*101+300, 0, 2pi+SinOsc.ar(0.01, 0, 0.5*pi)), 400, 700))), SinOsc.ar((0..5)+1*0.004, 0, 100, 400), SinOsc.ar((0..5)+1*0.006, 0, 0.4, 0.8)))})
)
Ndef(\saws).stop


 

//--pakt01
osx binary
c++ code
processing

Ndef(\moreSines).play
(
Ndef(\moreSines, {LeakDC.ar(Splay.ar(SinOsc.ar((0..20)/70+0.01, SinOsc.ar((0..20)+1*50+50+SinOsc.ar((0..20)+1/30), 0, 2pi), SinOsc.ar((0..20)+1/80, (0..20)/40, 0.2).max(0))))})
)
Ndef(\moreSines).stop


 

//--pakt00
osx binary
c++ code
processing

Ndef(\sines).play
(
Ndef(\sines, {GVerb.ar(Splay.ar(SinOsc.ar([100, 200, 300]+SinOsc.ar([0.11, 0.22, 0.33]), SinOsc.ar([0.1, 0.2, 0.3], 0, 2pi), 0.1+SinOsc.ar([0.01, 0.02, 0.03], 0, 0.05)), SinOsc.ar(SinOsc.ar(SinOsc.ar(0.13, 0, 5, 6), 0, 8, 50), 0, 1, 1), 0.7, SinOsc.ar(1.2, 0, 0.6)), 20, 5, 1, 0.5, 25, 0, 1, 1)})
)
Ndef(\sines).stop


atolf lftoa

using supercollider i reverse-engineered two old max/msp externals from cycling'74. they came as part of the pluggo installer and were compiled in the cfm binary format. this format is since long defunct and cfm externals can't be loaded into max/msp running under windows or newer intel macs (afaik). luckily i could still run the externals and helpfiles under max4.6 on my old ppc mac.

and as far as i could tell, the source code for these binaries were never released. so i took the trial&error route and managed to figure out how they work internally by using simple input strings like 'aa', 'ab', 'ac', 'ba', 'bb', 'aba', 'abc' etc. then i just observed the output arrays of floating point numbers and tried to mimic that in supercollider code. it was fairly quick to come up with the algorithms that encode (atolf) and decode (lftoa) shown below.

also a note on max vs sc: no way i could have solved this using max/msp only. algorithms like these are horrendous to implement with patchcords. see the mess in the screenshots below. also max/msp floatinpoint numberboxes as well as the [print] object does not show the whole 32bit float values! they round off to 6 digits after the decimal point. why? so max/msp can calculate just fine using 32bit floats as long as you don't try to print or output them in any way.

anyway, i first wrote RedALF for supercollider (it is now in the redSys quark) and from that i then patched f0.atolf and f0.lftoa (now part of my f0.abs max/msp abstractions).

(
~atolf= {|str|
        var res= [1/2**5];
        var tre= [2**12, 2**20, 2**28];
        str.do{|chr, i|
                var j= i.div(3);
                if(i%3==2, {
                        res= res++(1/2**5);
                });
                res.put(j, res[j]+(chr.ascii/tre[i%3]));
        };
        res;
};
~lftoa= {|arr|
        var res= "";
        arr.do{|val|
                var a, b, c;
                val= val-(1/2**5)*(2**12);
                a= val.asInteger;
                val= val-a*(2**8);
                b= val.asInteger;
                val= val-b*(2**8);
                c= val.asInteger;
                res= res++a.asAscii++b.asAscii++c.asAscii;
        };
        res;
};
)
a= ~atolf.value("aber")   //--> [0.055025476962328, 0.05908203125]
~lftoa.value(a)  //--> "aber"

sinusdeklinationen

a quick port of a very simple pure-data demonstration patch made by malte steiner. just to show one way how to go about things in supercollider.

get the pd patch here... sinusdeklinationen.pd

and then compare it with the following...

//--sinusdeklinationen by malte steiner, ported to sc by redFrik

s.boot;

(
SynthDef(\sinuscell, {|out= 0, pan= 0, amp= 0.5, fre= 400, atk= 1, sus= 0.2, rel= 1|
        var env= EnvGen.kr(Env.linen(atk, sus, rel, amp), doneAction:2);
        var snd= SinOsc.ar(fre, 0, env);
        Out.ar(out, Pan2.ar(snd, pan));
}).send(s);
)

(
var cells= [-1, -0.6, -0.5, 0, 0.2, 0.5, 0.4, 1];
~masterVol= 0.1;
cells.do{|c|
        Routine({
                inf.do{
                        var fre= 1100.rand;
                        var atk= 1.0.rand;
                        var sus= 0.2;
                        var rel= 1.0.rand;
                        Synth(\sinuscell, [\fre, fre, \amp, 1.0.rand*~masterVol, \atk, atk, \sus, sus, \rel, rel, \pan, c]);
                        (atk+sus+rel).wait;
                };
        }).play;
};
)

~masterVol= 0.2
~masterVol= 0.02

//stop with cmd+.

redUniverse: support for discrete worlds

clean-up #30:

as the last thing for this month-of-cleaning-up-old-code-and-taking-care-of-forgotten-projects, i finally wrote some methods that i had been planning for a long time. they add support for discrete worlds to my redUniverse quark.

it's all fairly simple.

in a 2 dimensional world there are 8 neighbouring cells/locations. the surroundings method returns them.

a= RedWorld(RedVector[100, 200])  //a 2d world
a.surroundings
[ [ -1, -1 ], [ -1, 0 ], [ -1, 1 ], [ 0, -1 ], [ 0, 1 ], [ 1, -1 ], [ 1, 0 ], [ 1, 1 ] ]

and in a 3 dimensional world, the number of surrounding cells grows to 26. that is 3*3*3-1 where the minus one is the [0, 0] location.

a= RedWorld(RedVector[100, 200, 300])  //a 3d world
a.surroundings
[ [ -1, -1, -1 ], [ -1, -1, 0 ], [ -1, -1, 1 ], [ -1, 0, -1 ], [ -1, 0, 0 ], [ -1, 0, 1 ], [ -1, 1, -1 ], [ -1, 1, 0 ], [ -1, 1, 1 ], [ 0, -1, -1 ], [ 0, -1, 0 ], [ 0, -1, 1 ], [ 0, 0, -1 ], [ 0, 0, 1 ], [ 0, 1, -1 ], [ 0, 1, 0 ], [ 0, 1, 1 ], [ 1, -1, -1 ], [ 1, -1, 0 ], [ 1, -1, 1 ], [ 1, 0, -1 ], [ 1, 0, 0 ], [ 1, 0, 1 ], [ 1, 1, -1 ], [ 1, 1, 0 ], [ 1, 1, 1 ] ]

and the numbers for 4, 5 and 6 dimensional worlds (not that i ever used >3) are 80, 242, 728 respectively. (a RedWorld can have any number of dimensions.)

also it is possible to not only get the directly adjacent cell, but neighbours further away. this example bumps up the surroundingArea variable from the default 1 to 2. now the surroundings are all the cells next to and two steps away from [0, 0].

a= RedWorld(RedVector[100, 200])  //a 2d world
a.surroundingArea= 2
a.surroundings
[ [ -2, -2 ], [ -2, -1 ], [ -2, 0 ], [ -2, 1 ], [ -2, 2 ], [ -1, -2 ], [ -1, -1 ], [ -1, 0 ], [ -1, 1 ], [ -1, 2 ], [ 0, -2 ], [ 0, -1 ], [ 0, 1 ], [ 0, 2 ], [ 1, -2 ], [ 1, -1 ], [ 1, 0 ], [ 1, 1 ], [ 1, 2 ], [ 2, -2 ], [ 2, -1 ], [ 2, 0 ], [ 2, 1 ], [ 2, 2 ] ]

that is 24 neighbour locations per single cell in a 2d world.

so the surroundings method only give relative positions and the size of the neighbourhood. not so useful. but there are the two other methods called surroundingLocations and neighbours that is what one should use. surroundingLocations takes an object and returns a list of locations depending on the current surroundings.

a= RedWorld(RedVector[100, 200])  //a 2d world
b= RedObject(a, RedVector[10, 20])  //an object at location [10, 20]
a.surroundingLocations(b)  //get the surrounding locations of object b
[ RedVector[ 9, 19 ], RedVector[ 9, 20 ], RedVector[ 9, 21 ], RedVector[ 10, 19 ], RedVector[ 10, 21 ], RedVector[ 11, 19 ], RedVector[ 11, 20 ], RedVector[ 11, 21 ] ]

and last the neighbours method that returns an array of any nearby objects.

a= RedWorld(RedVector[100, 200])  //a 2d world
b= RedObject(a, RedVector[10, 20])  //an object at location [10, 20]
c= RedObject(a, RedVector[11, 21])  //an object at location [11, 21]
a.neighbours(b)  //get the neighbouring objects of object b
[ a RedObject ]

the different worlds deals with border conditions differently. RedWorld wraps all the locations around and RedWorld3 filters out locations. compare...

a= RedWorld(RedVector[100, 200])  //a 2d world without borders
b= RedObject(a, RedVector[0, 0])  //an object at upper left corner location [0, 0]
a.surroundingLocations(b)  //get the surrounding locations of object b
[ RedVector[ 99, 199 ], RedVector[ 99, 0 ], RedVector[ 99, 1 ], RedVector[ 0, 199 ], RedVector[ 0, 1 ], RedVector[ 1, 199 ], RedVector[ 1, 0 ], RedVector[ 1, 1 ] ]
a= RedWorld3(RedVector[100, 200])  //a 2d world with borders
b= RedObject(a, RedVector[0, 0])  //an object at upper left corner location [0, 0]
a.surroundingLocations(b)  //get the surrounding locations of object b
[ RedVector[ 0, 1 ], RedVector[ 1, 0 ], RedVector[ 1, 1 ] ]

the neighbours method is quite slow at the moment, but i hope to be able to speed it up considerably later on.

anyway, here is the complete svn diff.

redLeech

clean-up #28:

code that performs itself. this is number six in a series all working in a similar manner. see low life, more low life and even more low life.
this virtual leech runs around the code and suck up words now and then. when it's full (c.size>30) it spits them all out wherever it happens to be. and some characters are lost so the code slowly disappears.
in the end of the video it got stuck in a loop so i killed it off manually with the delete key.

thanks to chris for the title.

supercollider document attached below. osx only afaik.

AttachmentSize
Binary Data redLeech.scd993 bytes

redUniverse: clean-up and some new features

clean-up #26:

my redUniverse quark still have a lot of features missing that i want to put in. it is endless work and i only get to it now and then. but at least after today the helpfiles are in a bit better shape, and examples are changed to use animate to run more smoothly (most now look a lot better!).

* new helpfiles for RedHiddenObject, RedParticle, RedBoid, RedRock, RedFood, RedAgent.
* slightly changed formatting for almost all the other included helpfiles.
* wrote addForceWander1D and addForceWander3D methods for RedBoid.
* wrote addForceAngular3D, pendulumOffset3D, pendulumLoc3D.
* added 2 boids examples and 1 pendulum to show the new features.
* changed almost all the other examples to use animate instead of play and to close the window at cmd+.

here is the complete svn diff.

Pages

Subscribe to f0blog RSS