Getting started with Clojure and Overtone

Continuing on from my previous post. I had a few issues getting up and running on my mac so thought I'd put a quick blog post up in case it helps anyone.

First I headed over to: https://github.com/overtone/overtone

And read this:

  1. Make sure you have a Java JDK version 6 or later.
  2. Download the lein script from the stable branch of this project.
  3. Place it on your $PATH. (~/bin is a good choice if it is on your path.)
  4. Set it to be executable. (chmod 755 ~/bin/lein)
  5. Run it.

Here's a bit more detail:

  1. First off I tried in the command line java -version but this isn't what you're after. You need the actual JDK, I'm not sure how to check if you have this installed, but I was pretty sure I didn't so went to google and typed Java JDK download and got to: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  2. To download this, open the link in a new tab, copy the contents and save this to a file called lein on your local machine.

  3. I'm not sure if this is the correct way to do this, but it worked for me. I moved the file lein created in the previous step to the bin folder in the root folder of my machine, a handy shortcut is to open the Finder, then Shift+Cmd+G then can paste in ~/bin to get to that folder.

  4. In Terminal (or I use iTerm, whatever you use for writing commands on the command line) paste in chmod 755 ~/bin/lein and hit enter so it runs. This will change the permissions of the file.

  5. To run it, in Terminal do bash lein and again hit enter so that commands runs.

I then then did lein new insane-noises, cd insane-noises, lein repl, but got:

1
2
3
4
5
6
7
8
9
10
11
12
༼ つ ◕_◕ ༽つ⚡  lein repl
nREPL server started on port 49492 on host 127.0.0.1 - nrepl://127.0.0.1:49492
REPL-y 0.3.1
Clojure 1.6.0
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e

user=>

For some reason not all the dependencies are included in the insane-noises/project.clj file, to fix this I had to add in the dependencies manually, so changed the project.clj file from:

1
2
3
4
5
6
(defproject insane-noises "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "https://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "https://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]])

to:

1
2
3
4
5
6
(defproject insane-noises "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "https://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "https://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"][org.clojure/clojure "1.5.1"][overtone "0.9.1"]])

saved the file, then when I ran lein repl the dependencies got downloaded and… woohooo!!!!! boom I'm in :)

1
2
3
4
5
6
7
--> Loading Overtone...

_____ __
/ __ /_ _____ _____/ /_____ ____ ___
/ / / / | / / _ \/ ___/ __/ __ \/ __ \/ _ \
/ /_/ /| |/ / __/ / / /_/ /_/ / / / / __/
\____/ |___/\___/_/ \__/\____/_/ /_/\___/

After this I was also able to clone Chris's repo: https://github.com/ctford/whelmed

I use some custom aliases to do this: g c [email protected]:ctford/whelmed.git which is basically git clone [email protected]:ctford/whelmed.git after that cd whelmed, lein run and now I get:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
༼ つ ◕_◕ ༽つ⚡  lein run
--> Loading Overtone...
--> Booting internal SuperCollider server...
*** ERROR: open directory failed '/Users/simonowen/Library/Application Support/SuperCollider/synthdefs'
Number of Devices: 2
0 : "Built-in Microph"
1 : "Built-in Output"

"Built-in Microph" Input Device
Streams: 1
0 channels 2

"Built-in Output" Output Device
Streams: 1
0 channels 2

SC_AudioDriver: sample rate = 44100.000000, driver's block size = 512
--> Connecting to internal SuperCollider server...
--> Connection established

_____ __
/ __ /_ _____ _____/ /_____ ____ ___
/ / / / | / / _ \/ ___/ __/ __ \/ __ \/ _ \
/ /_/ /| |/ / __/ / / /_/ /_/ / / / / __/
\____/ |___/\___/_/ \__/\____/_/ /_/\___/

Collaborative Programmable Music. v0.8


Hello Simonowen, may algorithmic beauty pour forth from your fingertips today.

late 0.026350804
late 0.026350804

and this is now playing Chris's song, lovely stuff, especially like the shudder sound.

I just need to try and find out what's going on with the *** ERROR: open directory failed '/Users/simonowen/Library/Application Support/SuperCollider/synthdefs' error now and I'm set.

Nice chatting to Chris afterwards, thanks again!

Browse by category: