Connecting an instrument into sonic pi live_audio

I’ve been looking around, but I haven’t come across instructions or recommendations on how to hook up an instrument to a computer and into Sonic Pi to use live_audio. Would someone lay out what would be necessary (beyond the instrument, like a guitar) in order to get it pulling in on a Windows machine or Raspberry Pi 3, such as cabling or connectors?

Any help would be greatly appreciated.

Use the channel opt.


Please do take a look at the documentation for the live_audio fn and also the included examples.

The simplest case to get audio from your sound card into Sonic Pi is:

live_audio :foo

This will read audio from the first input of the sound card and play it as a synth :slight_smile:

To choose between different inputs of a multi-channel audio card, the opt to use is called input: :slight_smile:

Alrighty, but I’m looking for a what kind of cable/hardware do I need to get my guitar plugged in to the computer. Something that is known to work,so I don’t have to spend money on several different products that won’t work to find one that works. I mean, is there like, a 1/4" plug to USB cable or something, that’s what I’m digging for. I’ve found many different products, but I was hoping to hear from someone who has already sorted through them and found what works.


if you just would like to plugin you guitar the Behringer Guitar Link UCG102 might be enough. I did buy it sometime ago, it works quite well and is cheap but I don’t use it anymore, because I 1. wanted have input options for playing live with others and 2. I wanted to have better latency values:

So you can try some sort of USB audio device (an external soundcard). I bought the Focusrite Scarlett 2i2 (there is also one by Steinberg about the same price region). You can reach quite low latency values and you can plug in instruments and/or microphones (2 line resp. instruments inputs). Mine works flawlessly with Linux (which is not a natural thing); before you buy get some information about the device and how it works with Windows (which usually is well supported).


Oh, yeah. I’ve only used live_audio a few times, although I’ve been experimenting with it a lot recently. I really should reread the documentation at some point.

1 Like

On a raspberry pi the add on pisound board works well but no that cheap. See site

(I use it)

Awesome! Many thanks!

I recently bought, installed the Pisound hat, plugged in my guitar and still got no sound. All tested okay per the checks I could find online. Any thoughts on what I should try? I did notice that live_audio did not auto populate when I typed into the sonic pi terminal.

I have just written a post to aid in setting up the pisound board with Sonic Pi which you can read here

Thanks! Found it very helpful, but I cannot get the live_audio thread to populate. Also, when I changed my input/outputs to the suggested, I get a cannot connect to server (only selecting defaults do I get a connection). I have re-checked my configure and all seems to be in order. Where do I go next?

The Sonic Pi gives me a runtime error of sonicpilang when Imtype live_audio.

You are using Sonic Pi version 3.0.1? live_audio is not available on earlier versions, and if you are getting an error message for live_audio that may be why.

I’m trying to use the Built-in Microphone with live_audio on a 2012 MacBook Pro. For some reason I can’t get it to play the input. When I plug in a USB microphone or audio interface live_audio works. Any ideas why it might not be working? I’m running Sonic Pi 3.2.2 on Mac.