Tuesday, May 07, 2013

Gates of Dawn

Windows has spontaneously imploded for me, leaving me unable to use FL Studio or other music software I'm used to. So, I'm taking the opportunity to get to grips with Pure Data.

The problem is, I've always found the UI of PD fairly fiddly and off-putting. I don't want to have to think about laying everything out in 2D space when all I'm really interested in is the flow relationship between objects. Also, I've never ... ahem ... quite worked out how to do reusable components. It looks laborious to me.

Theoretically, I'm much more attracted to the SuperCollider approach of writing code. But that has some quirks. Also PD seems to be running in more interesting places (eg. as an engine in Android and iPad apps) than SuperCollider.

Because of this I decided to look into the text representation of PD patches. It's very low level, but easy to understand. So I had a quick go at creating a Python library to generate it.

The first (after a day or so of work) draft is now up on GitHub.

Already, I'm pretty excited about this. It works the way I want to think about synthesis. Objects are connected by function composition. Here, for example, is how you take any signal and turn it into a feed to FM synthesis.

def fm(sig,id=1) :
    return sin(sigadd(
                sig,
                sigmult(
                   phasor(num(slider("fm_freq_%s"%id,

                                            -1000,1000))),
                   num(slider("fm_amp_%s"%id,-500,500))
                )
           ))


Every time you call functions like "phasor" and "slider" you get new instances of the objects, added to the patch. So this is actually a declarative description of the relations between objects. It's partly inspired by my playing with signals in Elm-Lang. Though there's nothing similarly clever happening here, it's just producing a text-file.

Sliders controls are layed out automatically. Once again, it's very crude and lacking. But enough to make a small workable instrument.

Anyway, as I continue to explore Pure Data I'll do it by adding to this library. Will keep you posted with updates and some musical examples soon.

No comments: