Demo of experimental Ableton Link with Sonic Pi

This video illustrates the excellent work done recently by Luis Lloret and Sam Aaron to bring Ableton Live link technology to the development version of Sonic Pi. It is planned that this exciting development will be further refined and included in the next release version.

In this video I use copies of the latest development built on my Mac and also on a Raspberry Pi 4 (from the github link branch), and use Ableton Live 10 to control them while they play the Bach example program included with Sonic Pi. This is modified by adding two lines to the Mac version
sync "/link/start" and use_bpm :link the second line replacing the use_bpm 60.
The Raspberry Pi version has the same two lines added, plus a third one set_audio_latency! -200 to the Raspberry Pi one, this last line adjusting for the longer latency in the Raspberry Pi so that its audio plays in sync with that of the Mac.
On Ableton I used an empty midi track, but recorded on the master track a varying tempo line, that started at 60bpm and rose linearly after 2 bars up to 120bpm at 12 bars then decayed again in two ramps back down to 60bpm. You can hear the smooth transitions of tempo as the two Sonic Pi instances play together.


Excellent work.
Looking forward to this, as it opens up more possibilities, especially apps.

Well done Luis and Sam.

1 Like

This is great! Do you know if it is possible to use this without Ableton? So instead of the “/link/start” message coming from Ableton, it comes from another instance of Sonic Pi? How would the code differ?

Hi @carltesta - Link is an open standard dual licensed under GPLv2+ and a proprietary license. It’s therefore integrated into many platforms already. See: Link-enabled music making products | Ableton.

Of course, this also means you can take advantage of the new support for Link with multiple instances of Sonic Pi connected to the same network in addition to any other compatible app or gear.

I’m currently working on a GUI metronome interface which will enable you to send link start and stop messages (there’ll also be equivalent API function calls to do the same from code).

I’m openly developing this stuff through the beta program. Beta1 just really represents a technical preview of the Link support. I definitely recognise that there’s plenty more work to be done before this is really polished and ready for a full release.


We did some initial preliminary testing of this feature. No Ableton used, just one Sonic Pi networked with an MPC, an Organelle, some other stuff. The Sonic Pi code used use_bpm :link, no link start/stop.

The good news is, it sort of works. It kept in sync using a metronome live_loop to keep the beat and was usable like that. Real-time bpm changes were erratic; at one point it seemed to respond to them, then it looked like it was not (without having to stop and start); still not sure what the deal is. But, other than that, it was working.

Hi there, what were you using to change the bpm?

The bpm changes were dictated by other machines on the network. The Sonic Pi log correctly shows /link/tempo-change cues.

Here is a little test I ran just now with the following, rather minimal, example:

use_bpm :link

loop do
  sample :bd_haus
  sleep 1

and another machine on a LAN running Bitwig.

Experiment 1: start Sonic Pi and Bitwig. Run the program. It starts drumming at 120 bpm. BPM changes in Bitwig are super glitchy: increases cause Sonic Pi to think it is thousands of seconds behind, decreases freeze it up (thousands of seconds ahead?)

Restart Sonic Pi… interesting; now tempo is changing as expected. Seems like a temporary issue/glitch with the operating system time or link clock?

However, now

use_bpm :link

live_loop :foo do
  puts 'BPM is ' + current_bpm.to_s
  sleep 1

live_loop :hmm, sync: :foo do
  sample :bd_haus
  sleep 4

does not respond to bpm changes. That is, it will print “BPM is 300.0” or whatever, but keep playing at the same tempo. That is what we were experiencing the other night. Paring it down to

use_bpm :link

live_loop :hmm do
  sample :bd_haus
  sleep 4

is OK again. Putting foo back in while running still OK, then stopping+starting makes it unresponsive again.

Interesting, this definitely needs a bit more investigation. I don’t currently have Bitwig - I’ve just tried things with Ableton Live, Resolume Avenue and some iPhone apps.

I have two main questions at this stage:

  1. Could you try changing the BPM from a copy of Sonic Pi with set_link_bpm! and see if that has the same behaviour.
  2. You mention “BPM changes in Bitwig are super glitchy” - is this something you also observe when Sonic Pi isn’t connected to the LAN? I’m wondering whether it’s possible that Bitwig is doing something unusual under the hood.

OK, apologies - scrap my questions, I’m definitely getting weird behaviour here too.

I’ll investigate and fix it up for the next Beta release. Thanks so much for bringing this to my attention!

I believe it might be this sync which is causing the issue. Could you remove it from your code and see if that “fixes” things for you?

Removing the sync does seem to fix it (i.e., changing the bpm works), but does that not defeat the purpose? After all, the metronome loop is not really going to just sleep 1 every time, more like

live_loop :foo do
  diff = @tau_api.link_current_time_and_beat(false)[1] % 1.0
  latency = 50.0
  x = ((1-diff) + 0 - rt(latency/1000.0))
  sleepytime = (x > 0.001) ? x : 1
  sleep sleepytime

In your case, the sync_bpm opt to the live loop isn’t actually needed. This is because all the live loops will start at the same time the first time you hit run, and also given you declared the bpm via use_bpm outside of the live loops, that bpm will be inherited as they start.

Just to track back here, I believe I have fixed the issue you observed in the dev branch on Github:

Core - work with current_bpm_mode where necessary · sonic-pi-net/sonic-pi@9c1f211 (

This will make its way into the next Beta release. @bugmenot2 thanks again for spotting and reporting it :slight_smile:

1 Like