So I got tagged for the “your life in six words” meme. Right now I’d have to say it’s “Ugly code makes Baby Jesus cry.” For instance:

a1 granule p4*k1,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,\

What we have here is a mess. It’s the code for a csound unit generator straight out of the manual. Look intelligible? Good! It does to me, too. Now if I were looking at that code, I’d have absolutely no clue what any of the various parameters are. The “a1” is a specific instance of that unit generator. (Csound isn’t really object-oriented, nor is it functional.) Granule is the name of the unit generator (pretend it’s like a function), and all the bloody p-things after it are p-fields, or specific parameters that unit generator needs. (Those are set in the score file, when the actual instrument you build in the orchestra file is called.)

Now, for the sake of the Poor Souls in Purgatory, you don’t have to leave your p-fields looking like that. It’s largely preferable if you don’t. I mean, think what it would be like, if you wrote that instrument one year, put it aside, and then came back to it years later. Or, God forbid, someone else would have to do something with it.

So here’s another snippet of csound orchestra file, this time written by my chair. (Email me if you want a link to the original. It’s about as elegantly-written as csound can be.)

; fm portion

; ratio sweep
if iratdif == 0 goto noratiomod

kratio oscil iratdif, iratcps, iratfn
kratio = kratio + iratio2

kcpsmod = icpscar*kratio ; ratio is M/C
krange = abs(idif * kcpsmod)
kdev = abs(ifmi1 * kcpsmod)

; fm

kampmod oscil1 0, krange + kdev, idur, idevfunc
amodout oscil kampmod, kcpsmod * aglfac, 1
goto aftermod

Now, this is legible, if a lot more complex than the other example. Everything is insanely well documented, all p-fields are assigned to variables (except a few that are csound idioms, so to speak.) He’s doing some fairly complicated things, but everything is defined (even the p-fields which are just csound convention: p1 is always instrument number, p2 is always start time, p3 is duration, p4 amp, and so on.) Sure, you’d have to know how fm synthesis works, but it’s legible. It’s got comments, and things are clearly defined. The mind boggles.


~ by Jen on April 16, 2008.

%d bloggers like this: