We had some fun at our first London Clojure Dojo last night.

In honour of St. Patrick’s Day, the list of suggested projects had an Irish theme and one of them leapt out at us right away.

Write an Irish Music Generator”

We felt well qualified:

So it had to be. We had a little over an hour and a half to cobble something together from scratch. It had the sniff of a challenge about it and there was guinness and pizza for fuel.

A few things were clear immediately:


overtone.core and (boot-external-server) got us started. Dan had the SuperCollider IDE open which might have been running the supercollider server. We weren’t sure… We had to kill a process or two along the way.

Everything we needed we copied and pasted from the Overtone cheatsheet and wiki docs and then iteratively and incrementally made it more Irish.

We couldn’t get the flute synth working with a sensible envelope in time so we stuck with an ugly saw wave but generally making noise wasn’t difficult.

Our namespace, diddly.core might be a fairly accurate genre description for some of our speaker-busting early experiments…

The Bodhran

This was nice and easy once the WiFi started behaving itself. One line of code and the Bodhran was ours, thanks to Overtone’s simple helpers for downloading samples from freesound:

(def bodhrun (sample (freesound-path 65833)))

The Diddly

Simplest, cheapest, quickest way to an Irish vibe. Mix together a lot of this:


and this:


Randomly. Interminably.


How did we achieve this? In the simplest way conceivable. We play a note on every first tick, every third tick and, half the time, on a second tick too.

Add in our kick drum and bodhran and it looks like this. Probably a bit of time reading overtone docs for at and friends could tidy this up somewhat:

(case (mod tick 3)
  0 (do (at (nome beat) (bass)) (at (nome beat) (play-note))) 
  1 (when (> 0.5 (rand)) (at (nome beat) (play-note)))
  2 (do (at (nome beat) (bod)) (at (nome beat) (play-note))))


We didn’t have time for any clever note selection. It was a case of pick a scale and select randomly from it for every note. So there is no state at all. On every metronome tick a pitch is selected fresh from the list with no regard for what has come before or what shall go after.

We went with pure D major, hoping for a fairly bright sound. A few brief experiments in the Mixolydian didn’t work out so we ditched them.

We stayed within a single octave to avoid crazy leaps and rigged the frequencies a little to cause the “melody” to hover around the tonic a little.

(def D-ISH [:D4 :D4 :D4 :E4 :F#4 :F#4 :G4 :A4 :A4 :A4 :B4 :C#4 :D5])

(defn play-note []
  (saw-note (rand-nth D-ISH)))

We paid no attention to the underlying harmony whatsoever, we just “played within the key” and relied on the pace of the diddly to iron out the kinks.

For harmony we just cycled a simple progression in D major by hammering each chord at the start of a bar. Nothing clever. No thought went into the progression at all. Just obvious chords for D major.

(def progression [[:D3 :major]
                  [:G3 :major]
                  [:D3 :major]
                  [:A3 :major]
                  [:B3 :minor]
                  [:A3 :major]
                  [:G3 :major]
                  [:D3 :major]])

  ; ...
  (when (zero? (mod tick 12))
    (at (nome beat) (play-chord (apply chord (nth progression (mod (/ tick 12) 4))))))

The Tempo

We started with what we thought was quite an Irish tempo. We were totally wrong. We had to turn the dial all the way up to eleven before it got near the vibe we were looking for.

It also seems that as Guinness flows the tempo has increase to keep up. This is perhaps not a new discovery.

The Result

Dan’s gist has the final result. I think it’s surprisingly effective.

We showed off the code, played the jig and we did a little dance too.

We did get a lot of jitter despite Dan having a pretty beefy laptop. This surprised us a bit. Nonetheless the timekeeping was good enough to convey the intended impression. We think everybody enjoyed it. We certainly did.

One day we’ll learn Overtone properly and do something really good with it.