Sonic-Pi Network Collaboration Ressources


#1

Hi everyone!

I’m still trying to put together a network based piece for Sonic-Pi. Do you know if Ableton Link, Carabiner and other technologies like this could allow me to :

  1. Run a Master Sonic-Pi on a local wifi network that would cue the beginning of each bar.
  2. Run between 3 and 8 slave Sonic-Pi that would catch the cue and try to do some latency compensation.

I’ve tried many things and solutions, but I still end up with too many milliseconds of delay between each computers. I’ve seen that Ableton Link may be something to try.

If someone has some experience doing this kind of things, let me know.


#2

This article Sonic Pi Orchestra may be of some use. You can use it just to send cues, rather than parts to play.
Basically for latency you find by trial and error the slowest (ie longest latency machine) and then delay commands to play notes on the others by an amount that gets them playing together. The latency shift is constant.
I find it is better if the broadcast machine is wired to your router, so that there is only one WiFi link on any path. Once you get more than one, you can get jitter.
I think xavierriley has done some work with Ableton Link, but not sure how far it has progressed.


#3

Hey Robin,

First I must thank you because I’m using your code snippets as a base to improve and reach what I’m trying to do. I’m using the same synchronisation method as you, but I think that our goals are different. In the videos you posted on YouTube, you are using one computer to trigger all the other computers, or you are always using a fixed material (a score you parsed so Sonic-Pi can understand it).

What I’m trying to do is to be able to improvise on 8-9 computers that are in the same room, without any kind of drifting tempo and be precise enough to be able for instance to create a drum pattern, with each drum being played by a different computer.

For now, the best solution I got involves using the rt command for everything, instead of using wait or sleep. It allows me to have a “close enough” type of synchronisation, without having to struggle on getting the best connexion possible. If the main computer sending cues is stable (no other programs running in background), I can do something that sounds like what I intend to do.

I would like to use something really strong that care about latency compensation in a fancy way, so Ableton Link seemed to be the good solution for me.

I’ve seen the GitHub post that @xavierriley made some times ago, and I’m really curious about how he managed to do that. That would be awesome for me to use Ableton Link.

EDIT: Here is what I got so far, running very smoothly on three computers.

The Sonic-Pi master is running this:

live_loop :sendsync do ; tick
  bpm=get(:bpm) # still got traces of your good old code, Robin.
  use_real_time
  use_bpm bpm
  osc_send "10.9.74.85",4559,"/sync",bpm # first Sonic-Pi client
  osc_send "10.9.91.248",4559,"/sync",bpm # second Sonic-Pi client
  sleep rt(0.01) # the less I sleep, the better the sync? 
end

On the client-side of things, here is what I got:

# FIRST COMPUTER #
live_loop :n1 do ; tick
      use_real_time
      b = sync "/osc/sync"
      play (ring :c3, :c3, :bb3, :ab3, :g3).look
      sample :drum_bass_hard, rate: 0.7, amp: 1 if bools(1, 0).look
      sample :drum_snare_hard, rate: 0.7, amp: 1 if bools(0, 0, 1, 0).look
      sleep rt(0.5)
    end

# SECOND COMPUTER # 
live_loop :n2 do ; tick
  use_real_time
  b = sync "/osc/sync"
  play (ring :eb3, :g3, :bb3, :c4, :eb4, :bb4).look
  sample :drum_cymbal_closed, amp: rrand(0.5, 1)
  sleep rt(0.5)
end

#4

Hey! Quick update that might interest some people here.

I’ve talked to dktr0 (David Ogborn) who is in charge of the ExtraMuros GitHub project. I asked him if it was possible to use his software with Sonic-Pi. He pushed a new update today to allow this. It is now possible to create shared network sessions of Sonic-Pi.

You can try it now.

I’m really glad that he did that, and I hope that it will help people like me who’d like to play with Sonic-Pi in a collaborative way. I haven’t tried it yet but I’ll do as soon as I can.


#5

Gave this a try. Seems to work OK. Just 1 server and 1 client so far. I’ll try several together now…
EDIT
now tried with two clients, and they play nicely synced together.
if you have different latencies on your computers running SP, you can delay the quicker one using the command set_sched_ahead_time! t where t is the delay that you need to sync them. Just run this in a buffer before you start using the system, and it will remember the delay set until you quit SP or reboot it.


#6

We finally found an efficient solution to synchronize any number of computers on the local network. There is a Link package for Max/MSP (Ableton Live) that you can use to send very regular cues to any clients running the same patch.

The Sonic-Pi scheduler sometimes struggle to keep a straight tempo, but if something like this happen, you can always resynchronize in the middle of the performance for better precision.

I might post detailed instructions to do that a bit later in the future. I just want to say that it’s a solution that works really really well, without any noticeable latency.