Sonic PI and Ableton Live

Gonzalo bellino
6 min readApr 18, 2020

--

In this publication, I will explain how to integrate SonicPI and Ableton Live to take full advantage of Ableton Live’s functionality by using the MIDI messages generated from SonicPI as if it were just another MIDI instrument in the rig.

Photo by Steve Harvey on Unsplash

Before we start with the basic details of connecting Ableton Live (www.ableton.com) and Sonic PI (http://sonic-pi.net/), let’s have a brief introduction

What is Sonic PI?
It’s a free and community software development environment that allows you to create and learn music, using your own programming language. Besides including an interesting set of effects, samples and synths (synths) it allows to create live music. By the way it is really intuitive and with a very clear user interface, with few but essential functions.It also includes connection capabilities for MIDI input and output and that’s why in this first tutorial we will show you how to use SonicPI to send midi messages and Ableton Live to process them and take advantage of the set of libraries of that powerful tool. At the end of the guide I include some links to go deeper into this product.
At the end of the guide I include some links to go deeper into this product in Spanish.

What is Ableton Live?
Very popular and practically a standard in music production software for the electronic music environment. Unlike SonicPI this product is a visual editing tool.

So let’s get to work, in principle this guide does not explain the details of installation of these products although both include guided installers to greatly facilitate their installation. As a pre-requisite to establish communication between SonicPI and Ableton we will need to install a “loopback driver”, that is, a software that emulates the existence of MIDI devices connected to the computer. We can also imagine this software as a creator of virtual MIDI instruments where there is no device connected, but another application that needs to emit MIDI messages or receive them for processing.
In Windows we can use the product LoopBe1 that is for free distribution or LoopMidi. For this tutorial we will use LoopBe1 from Windows.
When installing LoopBe1 it is possible to see a new icon in the taskbar and if you “click” on it you will see a window with the option to mute the traffic of MIDI messages processed by LoopBe1

In this first tutorial we will build a melody or musical phrase from SonicPI and send it to Ableton Live to select the desired instrument and apply a particular effect.

We start opening SonicPI
If you look at the screen you will see on the right side a “preferences” panel, if they are not visible you can display them using the combination ALT + P.

En la sección IO se pueden observar las salidas MIDI (MIDI outputs)

In the IO section you can see the MIDI outputs
In the IO section of the preference panel, you can view the list of MIDI devices detected by SonicPI. In particular, it is important to be able to view the “MIDI output” loopbe_internal_midi
So far we know that LoopBe1 was installed correctly and SonicPI has detected it!.👍

In the editor and as an example we will copy the following code and then execute it (CTRL + R)

use_bpm 120
use_random_seed 1
use_synth :piano
32.times do
play choose(scale(:E4, :mixolydian)), release: 1, port: "loopbe_internal_midi", channel:1
sleep 0.5
end

The above sequence uses the :piano synthesizer built into SonicPi.
Almost done from SonicPi, now let’s see what needs to be adjusted in Ableton Live and then go back to SonicPi to make the final adjustments and send this sequence directly to Ableton Live

We start with Ableton Live by opening the application
Go directly to the Options menu and select the Preferences option, from the “MIDI Link” tab we will add a new device to the “Input” list, which is obviously the “Internal MIDI LoopBe” driver. We will also specify that the new Input will have the Track set to “On”. This should be enough to set up Ableton Live. 👍

Now let’s get down to the business of fine-tuning the last details…
We create a new LiveSet and adjust a MIDI track

We must select the “MIDI Internal LoopBe” option from the “MIDI From” option, and we will associate only Channel 1 (Ch.1) to this track

This is important since Sonic Pi can send messages on different channels and we don’t want this track to receive all messages, only those sent on Channel 1.
Finally, we must incorporate at least one instrument to listen to the messages sent by Sonic PI and incorporate effects included from the basic version of Ableton Live 👇

Piano + dos efectos que ya vienen incluidos con Abeton Live

Piano + two effects already included with Abeton Live

We can now return to Sonic PI to make the final adjustments…
In our previous step through Sonic PI we incorporated a sequence of instructions that we will now adapt to use Ableton Live. So we’re going to replace the previous code with the following 👇

use_bpm 120
use_random_seed 1
32.times do
midi_note_on choose(scale(:E4, :mixolydian)), release: 0, port: “loopbe_internal_midi”, channel:1
sleep 0.5
end
midi_all_notes_off port: “loopbe_internal_midi”, channel:1
32.times do
midi_note_on choose(scale(:E4, :mixolydian)), release: 0, port: “loopbe_internal_midi”, channel:1
sleep 0.5
end
midi_all_notes_off port: “loopbe_internal_midi”, channel:1

The important instructions we’ve incorporated are as follows:
midi_note_on → Send the generated output to the specified port and channel. In the example we are sending MIDI messages through the virtual controller “loopbe1” and only on channel 1
midi_all_notes_off →. It cuts off the communication channel and it is important to always include this instruction at the end of the sequence if you do not want to hear residual noise in Ableton Live.

When running (ALT + R) the above example we should be able to hear the sequence in Ableton Live! 💪

And that’s it, summing up what we did to use both products:
We installed a driver to virtualize MIDI IN/OUT devices like LoopBe1
We take advantage of 2 SonicPi features to communicate with our compatible MIDI applications
We made simple adjustments to Ableton Live, created a track and associated instrument, and applied 2 effects.

Finally I leave 2 tips for Windows →
Tip #1: If you are using the internal board of a notebook or PC, the audio board driver may be configured to support exclusive use of the board for a single application, if this is the case, it is likely that one of the two applications (LivePI or Ableton Live) has reserved its use and thus you will not be able to use both applications at the same time. It is possible to disable this feature from the driver configuration

Tip #2: It is possible that after waking up the notebook from a SonicPi hibernation it stops transmitting messages to LoopBe1, a fix for this is to restart the application or you can try from the features panel, IO tab, the “Reset MIDI” option

And links to continue learning →

Here we are, I hope you have found this tutorial useful 💪 💪
until the next…

--

--