Processing, Minim, and Music

I recently discovered Processing. It’s a programming language and programming environment, based on Java, designed for artists, particularly those with an interest in what is sometimes called “generative art.” While Processing’s main focus is visual art, it includes a sound/synthesis library, Minim, which lets you programmatically tinker with audio and synthesis.

Creating audio with Processing takes me way back to the Atari 400 I got for Christmas one year, with which I managed to, hamfistedly but joyfully, create various noise makers including a decent drum machine.

I decided to give Processing a try and quickly found Dan Ellis‘s page of sample code, which included a nice little sine-wave piano, which I stole, extended a bit, and share with you here:

I do this with permission from Dan, who has moved on from Processing and now likes to do things in Pd, which is an open source branch of Max.

There is, these days, a version of Processing reimplemented in JavaScript called Processing.js, but, in my tests at least, there’s no support for audio. So, sorry that I had to resort to the Processing IDEs Java Applet export. Performance is better if you run it straight from the Processing IDE, of course. And there’s a link to the source if you want to give that a whirl (or hack your own).

Keyboard layout is simple. The Z-row is a C major scale. The A-row is the same, one octave up. The Q-row plays the major or minor third, relative to the root note below it in the A- and Z- rows. The number row plays the perfect fifth for the same. So, as a diatonic instrument, there are no wrong notes. And you can easily play major and minor chords or intervals by pressing keys in any vertical column. Make sure you don’t have caps lock on, as I’ve only defined the lower case characters so far.