Ubuntu + Overtone + VimClojure

I’ve been playing around with Overtone a bit lately, but I felt very limited with just evaluating code in the REPL. What I needed was a way to open a file in some text editor and sending expressions to the REPL to evaluate. Here’s my experience, hope it will save time for someone.

First, producing sounds from Overtone was not very easy for me. This was my first time with synthesizers in Ubuntu and there are some things to know.

What you want is to connect the following components together in a serie:

  • Jack (Qjackctl in apt-get)
  • Supercollider (apt-get)
  • Overtone (follow the instructions, which uses leiningen)

I installed Clojure and leiningen via apt-get.

First problem: Ubuntu uses pulseaudio as default sound server, which is blocking the underlying sound interface from Jack. A decision you need to make is if you want to connect pulseaudio and jack in a serie or if it’s ok that the “normal” system sound is not working while jack is running.

I started following the instructions described here first, but that screwed up my system after suspend and boot. Also, the volume was always at 100% in this options – not very nice when playing raw sinus waves.. The safer way is to follow option #4 from here, pausing pulseaudio while jack is running.

Now I could “lein” a new project and start using (use ‘overtone.live) to make sounds. First I started with the “Getting Started” instructions, but there are also many nice examples here.

The problem with the longer examples is that the expressions are often on multiple lines which makes it awkward to only use the terminal REPL. I felt I needed to use a text editor and eval the expressions from there instead.

From what I’ve read, emacs is the default choice for Clojure people, which is fine. You need to install emacs24 in order to use emacs-live. Here, I encountered two problems: Ubuntu has some strange hard-coded menu thingy going on and in combination with the problem that my Meta key in emacs24/emacs-live was not working at all, I finally gave up.

Next thing to try was to use Eclipse and the Clojure plugin CounterClockWise. Long story short, I managed to evaluate some Clojure expressions in Eclipse, but Overtone gave me some really strange error messages and pop-ups about exceptions. So I moved on.

The final thing to try was VimClojure, which was a success, for me at least. All I had to do was to follow the instructions on vimclojure-easy. Almost all, that is. Similar to Eclipse, the problem was not to evaluate Clojure code, but to get Overtone work. As noted on this page, you can choose to either use an internal or external SuperCollider (scsynth) server. Failing to get overtone.live to work, I tried overtone.core instead and executed boot-external-server. Here’s what you need to do, in more detail:

  • Install VimClojure, using vimclojure-easy
  • Create a new lein-project
  • Add the overtone dependency, described here
  • $ lein install (probably not necessary, but good for catching errors earlier)
  • $ cd new-lein-project
  • $ lein vimclojure
  • $ vim src/new-lein-project/core.clj
  • rF will reload the entire file, find more commands here
(ns new-lein-project.core) ;; Already evaluated after rF
;; Evaluate these expressions one-by-one with el
"It's working!"
(use 'overtone.core)
(definst foo [] (saw 220))
(foo) ;; OMG it's ALIVE!!!
(kill foo)

One very nice example (which I have currently only tried in a REPL with overtone.live, without VimClojure) is the piano example. When evaluated, it will download the entire internet (piano samples) and then play Steve Reich’s Piano Phase. I removed the last expression and increased the time between the notes, giving it a bit more ambient feel to it.

(player (now) 3038 (take num-notes (cycle piece)))

Happy hacking! :)

This Post Has 2 Comments

  1. vim_user

    Great, thanks. I’ve been using just the plain REPL despite its drawbacks. I’ll be trying your instructions later this weekend. Not sure if you know but — there are also more examples you can browse with (examples) at the REPL.

  2. Sebastian

    Very cool stuff : ). Got me intrigued. I think I will try this out on the Ras Pi!

Leave a Reply