translating @redFrick's tweets

65 views
Skip to first unread message

Roger Allen

unread,
May 14, 2013, 12:27:28 AM5/14/13
to over...@googlegroups.com
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

Sam Aaron

unread,
May 14, 2013, 5:26:46 PM5/14/13
to over...@googlegroups.com
Hey Roger,

great work. I haven't had time to go through it all in detail yet, but a couple of quick points:

* The limit you're running into w.r.t. topological-sort is just a hard limit (placed to detect cycles). This can easily be increased (I'll do this for the next version)
* Taking a minute to compile the synthdef is also a bug - we shouldn't be taking any longer than SuperCollider itself which does it in less than a second.

Feel free to file some GitHub issues...

Sam

---
http://sam.aaron.name
> --
> You received this message because you are subscribed to the Google Groups "Overtone" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to overtone+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Sam Aaron

unread,
May 15, 2013, 3:43:34 AM5/15/13
to over...@googlegroups.com
Also, for those interested, I've attached the GraphViz version of Roger's translation of Frederik's tweet - it's pretty intense!
red-frik-130511.pdf

Roger Allen

unread,
May 15, 2013, 10:02:50 AM5/15/13
to over...@googlegroups.com
That's fantastic, Sam.

I've put the issues from this thread into https://github.com/overtone/overtone/issues/231
and I've translated a couple more tweets (MUCH easier after the first one) here
and I'll add more to this as I go through his tweets. 

It seems like this project
would be generally helpful in making these translations automatically.  I'm not sure I'll get to this, so if anyone else wants to take a run at this--go for it!

And finally (I do run on...) these synths gave me the motivation to figure out how to allow shadertone to monitor taps inside of synthesizers.  On my tree, I have code that allows the "t0" tap from the t synth instance to be sent to the t0 uniform variable  in the t.glsl code via:
  (t/start "examples/t.glsl" :user-data {"t0" (atom {:synth t :tap "t0"})})
I had high hopes that I could make some thing interesting with a redFrik tweet shader, but making something that won't induce epileptic seizures is going to take some time.  I should be able to create a simpler demo to show how to do this, though...

Roger

Roger Allen

unread,
May 15, 2013, 10:48:59 PM5/15/13
to over...@googlegroups.com
I pushed this feature out to the shadertone repo[1] and spent some time making a "music video" demo with a redFrick tweet that now comes up when you type "lein run".  I continue to be astonished at how interesting < 140 characters can be musically.  I can't get the dang tune out of my head!

Some screencaps to entice you to try it out.  :)


Reply all
Reply to author
Forward
0 new messages