Experiments In Overtone

The Overtone project is Clojure -meets- SuperCollider. What does this mean? It means that it's using a very interesting programming language to write code for a very interesting music and sound-synthesis runtime. What that needs is a programming environment. While the project has their own ambitions, how far can we get in Field?

It's not clear yet, but it's straightforward to get started. First install Overtone and everything it needs. Thanks to the Clojure community's near obsession with build systems this ought to be very easy. Something like:

curl https://raw.github.com/technomancy/leiningen/preview/bin/lein > lein
chmod u+x lein
./lein self-install

That gets you leiningen (version 2), a popular Clojure build tool.

Next, lets make a lein project and package up everything that Overtone needs (we're doing this the "Clojure way" before doing it the Field way):

./lein new some-project
cd some-project

Next edit the project.clj file to include Overtone:

(defproject insane-noises "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"] [overtone "0.8.1"]])

And then automagically download and warp absolutely everything you need into one big jar:

../lein uberjar

That will build something called:


Open Field, switch to the plugin manager and drag that .jar file into the list. While you in the plugin manager make sure that the wrap plugin is turned on — it's very useful when you start writing serious amounts of code in non-Python languages. The jsrscripting_extension plugin should also be on — we'll be writing in Clojure, not Python.

Restart Field.

Next, install (SuperCollider)[http://supercollider.sourceforge.net/] and open it up.

Finally make sure that Clojure support is enabled in your Field — turn it on in the "lambda" tab (you might want to elect to do this automatically on startup)

Hello Overtone

Now we can say hello to Overtone. In a new code box, start off by telling the WrapInTransform plugin that this box is going to be completely in Clojure (or we can wrap everything we write in a new Text Transform):

To make sure everything is working, launch SuperCollider, and try executing this:

(use 'overtone.core)

You should get a response from Overtone (you only need to run the above code once per session).

Now, at last, we can get Overtone to sing hello:

(definst sin-wave [freq 440 attack 0.01 sustain 0.4 release 0.1 vol 0.4] 
  (* (env-gen (lin-env attack sustain release) 1 1 0 1)
     (sin-osc freq)

Many of the features of the text editor work automatically inside Clojure — command-return for line / selection execution; embedded GUI elements (at least the ones that evaluate to plain text rather than complex Python expressions); the execution ruler and so on. At this point you can spend a pleasant evening hacking on Overtone's example code in Field.

Python meets Clojure

Should Field get drawn deeper into Clojure as a language we'll see support for Field's animation and box idioms in Clojure. But there's actually already much you can do with just a tiny little bit of Python to glue your Clojure into the Field environment proper.

For example a box that starts and stops a noisy synth as Field's time line. First a definition, executed once:

(defsynth bizzle [out-bus 10 amp 0.5]
  (out out-bus
       (* amp
          (+ (* (decay2 (* (impulse 10 0)
                           (+ (* (lf-saw:kr 0.3 0) -0.3) 0.3))
             (apply + (pulse [80 81]))))))

Now in Python, in a separate box:

def start():
    _self.b_ = _clojure.bizzle(0)

def stop():

_r = (start, None, stop)

Now we can litter our canvas with these boxes (command-shift-drag to duplicate!) and scrub them with the red-timeline:

We're just beginning to scratch the surface of what we can do with Overtone — unlike the MaxPlugin, the SuperCollider runtime is actually being hosted inside the same process as Field, so we can transport control- and even audio-rate material between the environments. We ought to be able to visualize analysis and control information by piping material straight out of SuperCollider and into Field's graphics system for example. And we ought to be able to come up with a whole bunch of ways in which the graphs and UI design aspects of Field can be brought to bear on Overtone's live coding story.

Stay tuned.