Saturday, May 16, 2009

Archaeopteryx: Music Production Use Case

I made a drum & bass track this morning, in about an hour, that I think is pretty good. I have no doubt that it's good for something I made in an hour, but I think it also stacks up well against similar or equivalent drum & bass I made a few years ago to which I devoted a lot more time.

I started with drum sounds and Amen samples from a previous sketch, and generated an Archaeopteryx MIDI file. I then generated three more MIDI files with Archaeopteryx, gathered drum sounds for those MIDI files, and added several loops.

Here's the sequencer window, from Reason:

Since many people who read my blog don't use Reason, I'm showing you this just because it looks cool.

Here's something a little more useful:

This is the sequencer window. The first four channels - regular, amens, glitchy, and vocoded - represent Archaeopteryx-generated drum MIDI. The last four channels - Dr. Rex 1-4 - represent loops. If you focus on the loops it's pretty obvious there's a very regular grid going on. Dr. Rex 1 plays a loop at the end of every 16 bars. Dr. Rex 2 rests for 32 bars and then plays for 32 bars, and the pattern repeats every 64 bars. Dr. Rex 3 rests for 64 bars and then plays for 64 bars, and the pattern repeats every 128 bars. Dr. Rex 4 throws a little variety into the mix, but not much, by resting for 64 bars, playing for 128 bars, and then resting for the remaining 64 bars.

It's less obvious, but the Archaeopteryx channels use a similar grid. I've forgotten the details, but I believe it goes like this: vocoded repeats a rhythm for 32 bars, and then generates a new one; regular repeats a rhythm for 16 bars, then generates a new one; amens repeats a rhythm for 8 bars, then generates a new one; and glitchy repeats a rhythm for either 4 bars or 2 bars, and then generates a new one. I could have gotten some details wrong, but the principle is obvious.

You can't see the grid there, because it's all in the details of the MIDI, and at this viewing level the sequencer just represents that MIDI as a thick red line. Since music requires both clear rules and violating those rules, I also added some edits to break the regularity of the grid. However, the Archaeopteryx channels all come from very nearly the same code.

It all changes based on just one magic number.

One major goal of Archaeopteryx: it exists to help me get better at making music. Ramon Leon told me about an amazing talk at a Smalltalk conference where one of Smalltalk's originators - I believe it was Alan Kay - explained his belief that if you want to understand something, the best way is to automate it in code. If I recall correctly, he also gave some examples from his experiments where he first taught children basic programming and then taught them how to use their programming skills to learn other skills.

Anyway, the goal: get better at making music. One way to do that is to use new tools of analysis to understand music better. If you look at the sequencer window picture, you don't see any evidence of the regular pattern driving all the drum patterns at a fundamental level. You don't even see it if you zoom into the next level of resolution.

No music software exists, to my knowledge, which can perform the sophisticated visualization and analysis necessary to reveal the meta-pattern that all these drum patterns share. However, if you reduce it to code, it's easy to spot. The only thing that changes is the magic number.

Of course any time you've got code which only changes by one value, the smart thing is to parameterize that value, and the fact that I'm using a magic number at all suggests a refactoring in itself. But refactoring Archaeopteryx will have to wait. Archaeopteryx is a sprawling, Perlish mess, and I say that with pride. You could replace most of its lambdas (at this point) with more traditional OO structures, but that's a tangent. It's that way because I needed the power of lambdas and flexible programming to get to the point where I had anything worth refactoring in the first place.

Likewise, I'd prefer to make music that was better than the music I made five years ago, as opposed to making equally good music in less time. However, all this serves as a good example of why I've stopped thinking about Archaeopteryx in terms of live performance. I always pay attention to the 80/20 rule. Archaeopteryx live fails that rule: there's a lot that could go wrong. Tools like Ableton Live win. But Archaeopteryx as a tool for rhythmic complexity wins. This track contains around ((256 / 32) + (256 / 16) + (256 / 8) + (256 / 4)) distinct rhythms, which is to say 120. The actual number I don't know - it could be 256/2, not 256/4, plus you'd have to figure out how many I threw away with edits and added with loops - but the point is, use a tool for what it does well. Archaeopteryx does rhythmic complexity well, right now, which wins out in some important ways over its hypothetical ability to do maybe-useful things with live performance someday.