I’ve been working out how to use Rack and Sonic Pi together live, so I thought I’d share my setup ideas.
I don’t really need to do this - I could do everything in either one probably. But I like them both so I want to, that’s the motive.
There’s a lot of crossover in terms of functionality between the two, and loads of ways I could think of: Rack driving Pi, Pi driving Rack, separate computers, one computer… But I want to use them both as independent instruments, working together.
The big difference between Rack and Sonic Pi (for me) is the timing model. As I understand it, Rack emulates real time by getting a lot of the CPU and using it efficiently. If there’s a resource shortage, it can stutter and lose a bit of time. Whereas Sonic Pi has a scheduling model that guarentees where sounds will be placed in time - unless something goes really wrong.
My analogy as a reliable drummer is that when I drop a stick, I don’t pause the groove to pick another up. There may be a short break in service, but I’ll continue in sync and tempo, unless I fall off the throne. That’s what Sonic Pi gives you. That makes it good for being the primary clock. So as well as playing what it’s playing (loops, samples, sequences…usual stuff) I’ve got it sending out a message that works as a timing pulse for VCV Rack.
Again, several ways to do that e.g. two computers, midi cables, midi pulse is the obvious one. But I want to have the option of running everything on one PC, and that’s a problem for midi as both apps try to grab the midi inputs. Instead, I’ve got Sonic Pi sending out an OSC message “/pulse” and using
Cockos OSCII Bot https://cockos.com/oscii-bot/ (the Reaper people) to pick that up and turn it into a midi pulse, using loopMidi http://www.tobias-erichsen.de/software/loopmidi.html that’s easy to pick up in Rack and turn into a clock reset.
This works for two PCs, or Rack on a PC and SPi on a Raspberry Pi. Which is my preferred mode, as then I can put the two outputs through an analogue mixer.
So now I can run the two things with all their clocks nicely in sync, and mix in/out the various voices on the fly.
OSCII Bot runs off EEL script, very efficient here’s my snippet to do this https://gist.github.com/soxsa/1ec89e49285ad3f72c933bb72254af3c I know there’s an OSC module for Rack, and that works well too. But it does use quite a lot of CPU as it’s general purpose whereas the OSCII Bot/EEL script is just doing the one thing so very lightweight.
Hope this helps someone wanting to do similar things. Also I’d be pleased to compare notes if you’ve got a different setup.
One day I might look at writing a dedicated OSC module specifically for syncing. I could even have it set the clock tempo too. Not from a beat, but explicity sending over a CV via OSC. That sounds like fun.