Overtone in a Ubuntu VM

01 Jan 2015

This is a guide to getting Overtone working in a virtual machine using Ubuntu 14.10 as the guest. The host system I am using is Windows 8.1, but the guide should hopefully work for other host systems as well. I tried VMware Player first but had problems getting JACK audio working. This lead me to use VirtualBox instead.

Getting Ubuntu up and running in VirtualBox

Download and install VirtualBox for your host system from the VirtualBox download page. Create a new VM (virtual machine). By naming it Ubuntu, VirtualBox will select the type and version as Linux Ubuntu for you. After the VM is created select it from the list and press Settings. Enable shared clipboard by going to General -> Advanced -> Shared Clipboard and change it to Bidirectional. It's a good idea to go to Display -> Video and increase the dedicated Video memory and enabling 3D acceleration. The VM is now ready for performing installation by pressing Start and selecting your Ubuntu ISO. Complete the installation.

I had some screen artifacts during the installation. StackOverflow helped me and I fixed the issue by hitting Ctrl+Alt+F1 and then Ctrl+Alt+F7.

Fixing screen resolution and clipboard

The VM in it's current state will not detect if you resize the VM window and the previously enabled shared clipboard will not work either. StackOverflow helped me again and I found at that to fix this we need to install the VirtualBox Guest Additions.
Run the following command in a terminal:

sudo apt-get install virtualbox-guest-dkms

Restart the VM.

Setting up dependencies

With a working VM running Ubuntu it's time to set up the dependencies for Overtone. Let's start by installing all the packages we will need from apt-get.

Integrating PulseAudio with JACK

If you are fine with having to start JACK on every boot you don't need to perform the following steps. The default configuration of PulseAudio yields control of the audio equipment to JACK when the JACK server starts. But PulseAudio will not be able to receive input or send output of any audio signals on the audio interface used by JACK by default.

PulseAudio configuration

You'll need to edit the PulseAudio configuration file to use the JACK module. Be careful! You will be editing an important system file as the root user!

Run the following command in a terminal:

sudo gedit /etc/pulse/default.pa

Add the following lines, underneath the line that says #load-module module-alsa-sink:

load-module module-jack-sink
load-module module-jack-source

Restart PulseAudio by running the following command in a terminal:

killall pulseaudio

PulseAudio restarts automatically. Confirm that this has worked by opening QjackCtl. The display should confirm that JACK is "Active". Uncheck Setup... -> Misc -> Stop JACK audio server on application exit. Otherwise QjackCtl will kill JACK when you close it and all sound will be gone.

Leiningen

Leiningen is the project manager used by clojure. Install Leiningen by running the following commands in a terminal:

The bin directory will be added to $PATH automatically if you restart the machine but you can also run:

export PATH=$PATH:~/bin

to add it directly without restarting.

New clojure project

With Leingen installed we are ready to start programming if we want.

Create a new clojure project named tutorial by running:

mkdir ~/src
cd ~/src
lein new tutorial

You can start a new REPL using

lein repl

This is all you minmally need, but I find it nice to have a good IDE when I program.

Installing IntelliJ IDEA and the Cursive plugin

I have tried several IDEs for clojure and I find IntelliJ IDEA the easiest to set up and use. Download the IntelliJ tarball from the IntelliJ IDEA download page. Extract the contents to where you want it installed.

(I choose to extract the contents of the first folder (for me named idea-IU-139.659.2) to ~/programs/intellij/)

You can now follow the install-Linux-tar.txt. I have written out the steps I used below:

Navigate to inside the IntelliJ installation directory with the terminal and then into the bin folder. Start IntelliJ by running:

./idea.sh

The installtion wizard will help you with creating a desktop entry.

Cursive plugin installation

Now it's time to install the Cursive plugin. Follow the installation guide from the cursive plugin userguide. I have written out the steps I used below (for IntelliJ 14):

To install the plugin, open the IntelliJ Settings, then select Plugins -> Browse Repositories -> Manage Repositories. Add a repository with the url:

http://cursiveclojure.com/plugins-14.xml

Return to Browse Repositories, then in the Repository: dropdown select the new repo. You should see a plugin called cursive-0.1.xx (where xx is some version number). Install it using the install button, then close the Browse Repositories window and the Settings window. Restart IntelliJ when it prompts you to.

Hack away!

The setup is now done and it's time to start making some music! In IntelliJ select Import project and select the project we created earlier. Select Import project from external model, and then Leiningen. Press Next a few times until it's time to select a project SDK. Since this is our first run we need to add a new JDK. Press the plus and then JDK. IntelliJ will find the jvm folder and you select the java-8-openjdk folder. Press Next and then Finish.
Alt+1 will open the Project tool window. Open the project.clj and add

We need to start a REPL and load our code. Right click the project and press Run 'REPL for tutorial'. Wait for the REPL to start. To load our code have the tutorial.core file opened and focused and click Tools -> REPL -> Load file in REPL.

Wait for the Overtone welcome message, then to change the REPL namespace to the tutorial.core file we need have it opened and focused and click Tools -> REPL -> Switch REPL NS to current file. If it all works, running: