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