VCV Rack and Sonic Pi Together

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 (the Reaper people) to pick that up and turn it into a midi pulse, using loopMidi 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 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.


To add, a snippet for what the OSC pulse looks like from SPi. This loop is a 4/4 bar and the time_warp line places the pulse send just before the end of the bar to account for latency. It means do this at 4 beats minus 50ms. Very much like you can do in DAWs, where you can advance midi sends for the same purpose.

live_loop "bar" do
  time_warp 4.0 - rt(0.05) do
    use_osc "", 4560
    osc "/pulse", 49
  sleep 4

I’ve augmented this setup with 2nd PC running a three-voice VCV Rack patch, driven from Sonic Pi over midi. Because the note scheduling is all done in Sonic Pi rather than Rack modules, there’s more CPU resource available for the voices.

So now the setup is:

  1. Raspberry Pi / Sonic Pi playing it’s own voices, and sending OSC sync pulses to VCV Rack 1 and midi notes to VCV Rack 2
  2. VCV Rack 1 - patch with it’s own voices, clock, sequencers etc. aimed at live playing
  3. VCV Rack 2 - ‘dumb’ patch that plays midi notes scheduled from Sonic Pi

In use, I can live-code Sonic Pi, and use the Raspberry Pi to route keyboard midi to any of the voices, including hardware synths (I got a Volca FM and Behinger Crave to experiment with this).

Quite a lot to manage, but a hugely flexible live setup on a budget.

The Rack patch has one voice per row, each on a different midi channel

1 Like