I don't know where I got the pointer to this guys tweets, but he's making some amazingly dense, fun tweets of Supercollider code. I picked this one to translate and learned a few things from the attempt. I thought I'd write it up here for those who might be interested.
The tweet is here https://twitter.com/redFrik/status/333317729073381377
play{a=LFSaw;mean({|i|Ringz.ar(Blip.ar(a.ar(i+1/[3,4])>(a.ar(i+1/8)+1)*25+50,i+[2,3])*a.ar(i+1/50,i/25),i+1*99,0.1)}!50)/5}
Go plop that into Supercollider and shift-enter to hear it. Neat, huh?
Okay let's try to translate it with some reformatting...
;; play {
;; mean(
;; { |i|
;; Ringz.ar(
;; Blip.ar(
;; LFSaw.ar(i+1/[3,4]) > (LFSaw.ar(i+1/8) + 1) * 25 + 50,
;; i+[2,3]
;; ) * LFSaw.ar(i+1/50, i/25),
;; i+1*99,
;; 0.1
;; )
;; } ! 50
;; ) / 5
;; }
I couldn't find "mean", but I think "mix" does the same thing after a few experiments. At first, I had no idea what |i| might mean, but I found out (only by looking in the Supercollider book I bought) that { |x| x }.3 creates a vector of [0 1 2]. Happily, that translates to a (for [x (range 3)] x).
One thing that totally screwed me up for a while is that precedence in Supercollider is strict left-to-right (ugh, as if that language wasn't crazy enough!). So, i+1/50 is really (i+1)/50.
Along the way, I got this message with the default overtone settings
exception in GraphDef_Recv: exceeded number of interconnect buffers.
A google found the workaround was to increase the wire-buffers, so add
:sc-args { :max-w-buffers 512 }
to .overtone/config.clj but that still doesn't get it working. If the for loop exceeds 39 you get
Exception Invalid ugen tree passed to topological-sort-ugens, maybe you have cycles in the synthdef...
overtone.sc.synth/topological-sort-ugens (synth.clj:415)
So, I think there is a bug in Overtone--Sam, should I write an issue on this? The code works fine up to 39, but 40 and higher causes that failure.
Okay, here is the [mostly] final result...it takes a full minute to compile for my i7 MacBook Pro, so be patient...
(defsynth red-frik-130511
[]
(out 0
(/ (mix ;; docs suggest this is the same as 'mean'
(for [i (range 39)] ;; 40 starts fail, see above
(ringz:ar (* (blip:ar (+ (* (> (lf-saw:ar (/ (+ i 1) [3 4]))
(+ (lf-saw:ar (/ (+ i 1) 8)) 1))
25)
50)
(+ i [2 3]))
(lf-saw:ar (/ (+ i 1) 50)
(/ i 25)))
(* (+ i 1) 99)
0.1)))
40))) ;; reduce volume to avoid clipping
(red-frik-130511)
sounds very similar to the equivalent code in supercollider...
play{a=LFSaw;mean({|i|Ringz.ar(Blip.ar(a.ar(i+1/[3,4])>(a.ar(i+1/8)+1)*25+50,i+[2,3])*a.ar(i+1/50,i/25),i+1*99,0.1)}!39)/40}
That was a fun little challenge--go check out @redFrick's tweets. You can also see my travails in the gist I used here https://gist.github.com/rogerallen/5563902
Cheers,
Roger