Live Coding Preview Functionality

I’m wondering if there is a functionality to have listen to a “preview” during live performances before I commit to send it out to the audience.

What I’d like to see is to live code (as normal), but only I can hear it in my headphone (when I hit R), but there should a second buffer (or editor) where I can send the code for the audience. This way I could always preview for myself each change before I commit to send it to the audience live.

Is this possible with the current version? Or is there a hack to do so?

I was thinking to maybe run two Sonic PI instances, attached to two audio outputs, one is local (headphones), other one is for the audience, and with a hotkey macro copy the whole code from one Sonic PI instance to the other. But this sounds very hacky, I’m wondering if there is a better / built-in / more mature solution for this.

Hey hey @dh2k :slightly_smiling_face:

There is no ‘dedicated’ function for this. Having said that, there are a handful of ways you can achieve it - such as the dual Sonic Pi instances. As you suggest though, it’s quite a brute-force method and there’s likely a few better options.

One method that may well be worth using is to make use of the :sound_out_stereo fx. Details are in the in-app Help panel under the ‘Fx’ tab, but the TLDR is that this allows you to pipe (stereo) signals to specific sound outputs on your current device.
So, if you have a sound device which has multiple output channels, you could route the ‘DJ-only’ sounds to specific ‘preview’ channels.
I’ve never really tested it myself, but here’s an example that shows the basic idea:

# Eg. Headphones attached to an alternate output on your device
with_fx :sound_out_stereo, output: 3, amp: 0 do
  live_loop :testing do
    ...
  end
end

# Live to audience
live_loop :live do
  ...
end

Does that fit your needs at all? :slightly_smiling_face:
(Oops, forgot about amp: 0 - added :sweat_smile:)

There are also some details in Tutorial chapter 13.3 - mostly describing sound_out, but the stereo version is similar.