I just started using SonicPi on my pi4 and cannot get sound to my USB audio interface. The interface itself is a Behringer UCA222. I am able to get sound everywhere else in Raspbian, just not in SonicPi. The weird part is that if I change my sound device to HDMI, SonicPi plays through my monitor speakers without issue. Is there anything I can do to troubleshoot the issue? I attempted to launch qjackctl. My only option for routing was the input/output from Super Collider. I did not see any options for my usb device. The three interface options in qjackctl settings are HW: AlSA bcm2835, hw:Codec usb audio codec, and hw:Codec,0 usb audio (hw1:0).
I have the same issue. I read somewhere something about changing the default audio device, but I wasn’t clear on how that was being done and it didn’t solve my problem of needing to be able to have two users, one using the analog audio and the other using the UBS concurrently. I see this topic is over a month old with no answers, so I’m hoping to see something happen.
Hi there,
unfortunately I don’t currently have the resources to support Linux at this stage.
There used to be a handy audio-output control in the Sonic Pi preferences, but the Raspberry Pi Foundation requested that I remove it so I did.
You will need to use the Raspbian settings to switch audio output. Also, be aware as the previous poster pointed out that Sonic Pi uses jack to send audio, so this may also need to be configured correctly.
Others in this forum who may be using Raspberry Pis may be able to help. Additionally the Raspberry Pi forums might also be able to help you
Good luck and if you find a solution please do share it with us all here!
Hi,
I can not help with the Raspberry, but I assume this is very similar to Linux, because as Sam notes both use Jack. I have a Focusrite Scarlett 2i2 (USB), which I can use without any hassle with Sonic Pi. You don’t have to configure Sonic Pi to use your USB-Audio-Interface, you configure Jack to do so and then Sonic Pi uses what Jack supplies.
Here is what you could try:
arecord -l
**** Liste der Hardware-Geräte (CAPTURE) ****
Karte 0: PCH [HDA Intel PCH], Gerät 0: ALC269VC Analog [ALC269VC Analog]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Karte 1: USB [Scarlett 2i2 USB], Gerät 0: USB Audio [USB Audio]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
(Sorry, output is partly in German). Plug in your audio interface and use e. g. arecord
to find out your sound cards. I then have a simple bash script which either uses my USB-Interface …
#! /bin/bash
pulseaudio --kill &
jackd -d alsa --device hw:USB --rate 48000 --period 512 --nperiods 3
sleep 1
qjackctl --start &
sleep 1
sonicpi &
or the internal soundcard
pulseaudio --kill &
jackd -d alsa --device hw:0 --rate 44100 --period 1024 &
# instead of "hw:0", "hw:PCH" should also work but I didn't try
sleep 1
qjackctl --start &
sleep 1
sonicpi &
Actually I have some more things going on, which have to do with my specific setup. What I posted should be enough; of course you will have to find out which Jack settings work best for you.
I am sure this can be done more elegantly, but it does the trick for me.
Let me know, if this is of any help.
Thank Martin!
That sounds reasonable. However, when I try to kill pulseaudio, I get
[pulseaudio] main.c: Failed to kill daemon: No such process
And then, just to check:
jackd -d alsa --device hw:USB --rate 48000 --period 512 --nperiods 3
`default’ server already active
Failed to open server
So, I’m not really sure what’s going on.
Oddly, arecord -l produces
**** List of CAPTURE Hardware Devices ****
card 1: Device [USB Audio Device], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
Which isn’t even showing the on board audio, which does work.
Hi @iamchrismoran,
well it seems 1. pulseaudio
isn’t running at all. So simply skip this. And in this context 2. it makes totally sense, that Jack
is already running to give you sound at all. I think I would try to kill the Jack
process just to see, if you can call it again with jack -d ...
and your USB device.
But you are right: It seems weird that your onboard card doesn’t appear. There are some other commands to list audio devices. You can also start alsamixer
(console) and use F6 to list the devices - just to check whether this shows something different.
Sorry that I can’t be more specific, this is somehow poking around in the dark. Maybe the Raspberry Pi Audio Configuration docs will help. Interestingly it says:
The Raspberry Pi has two audio output modes: HDMI and headphone jack. You can switch between these modes at any time.
Just tried an experiment on my Pi4 with fresh install of latest Buster 2020-02-05.
I have a cheap plugin usb dongle 3D SOUND which I plugged in.
It was recognised by the audio select or (which you get to by right clicking the loudspeaker symbol on the desktop.
In order to use it with Sonic Pi you have to configure jackd to work with it. The easiest way to do this is to use the Qjackctl GUI control for jackd. This is installed by default on Buster, but is not enabled in the Menu. This is easily resolved by selecting Main Menu Editor from Preferences on the Main Menu, and then navigating to Sound & Video on the resulting window, and ticking the box beside QjackCtl to enable the entry in the menu. Click on OK to close the Menu Editor, and then you will find QjackCtl on the Sound & Video section of the Main Menu from where you can start it running.
Now click the setup button.
On the parameters tab you can adjust the Sample Rate, Frame/Period and Periods/Buffer.
These will affect the audio latency, and it is a trade off to get low latency, versus the audio breaking up because there is not enough time for it to be processed. With the USB card I had I could use the settings shown, whereas you needed a larger buffer size 1024, 0r 2048 with the built in audio on the Raspberry Pi. If you get a lot of break up on the settings you choose, you can alter then, and restart qjackctl and then Sonic Pi again. If you have an older Pi, you will also find that you need a larger buffer.
The Advanced tab lets you specify which audio card to use. I find it is safer to specify this directly rather than use default. Here I specified USB Headphones for the Output Device and USB Audio (hw,0) for input
You can leave other panels as they are and click OK to save the settings.
BEFORE you click the start button, it is a good idea to make sure that jackd is not already running. If you have used Sonic Pi in the current session (without qjackctl) then it leaves the copy of jackd running that it starts up.
start a terminal window, and type killall jackd in it, then close the window again.
Now click the start button for QjackCtl and the screen will “light up” all being well as jackd starts up.
Now you can start Sonic Pi. (For this demonstration I used the version supplied with Buster, although it is in fact cut-down and doesn’t support Midi or OSC calls, and I usually use my own build of Sonic Pi 3.2dev which does).
When Sonic Pi has started, bring QjackCtl to the front again.
Open the Connext Window.
You should see that SuperCollider output is connected to the system audio input.
If your usb card also supports input, you can open the system output (rather confusingly this is your microphone input) and connect it to SuperColliders input ports (by default 2 available in Sonic Pi).
In my case it was a mono input so there is only one connection to make.
Now all being well you can start playing Sonic Pi through your audio USB output.
Whn you quit Sonic Pi, you can quit jackd in QjackCtl then close that down.
On subsequent runs, QjacCtl will remember your audio settings and you just start jackd from it BEFORE you start Sonic Pi. You will still have to connect the input if you want to use that. It is possible to automate that, but I think this post is long enough already!
Finally to whet your appetite, here is the same setup, this time with Sonic Pi 3.2dev with new scopes and transparent screen.
have fun!
Thank you for this post!
My hardware setting is 8 channel audio board called Octo audioinjector on top of the RPI4.
I got QjackCtl setted up and working, but I have for Supercollider only two audio outlines and for Audioinjector eight.
I can connect those two Supercollider audio lines to any audioinjectors eight outputs and those are working fine.
Now I like to expand Supercolliders audio lines.
Is there a way to increase Supercolliders audio outputs from two to eight so that all eight channels can play different sound simultaneously?
Do Sonic PI support multi-channel audio output? If yes, how you activate them?
You can edit code in Sonic Pi yourself. In version 3.2.2 on the Pi it is installed under /opt
If you navigate to /opt/sonic-pi/app/server/ruby/lib/sonicpi and open the filr scsynthexternal.rb you can modify the number of input and output channels used by scsynth. The code is in the section starting around line 486 (in version 3.2.2)
boot_and_wait("scsynth",
"-u", @port.to_s,
"-m", "131072",
"-a", num_audio_busses_for_current_os.to_s,
"-D", "0",
"-R", "0",
"-l", "1",
"-i", "2",
"-o", "2",
"-z", block_size.to_s,
"-c", "128",
"-U", "/usr/lib/SuperCollider/plugins",
"-b", num_buffers_for_current_os.to_s,
"-B", "127.0.0.1")
`jack_connect SuperCollider:out_1 system:playback_1`
`jack_connect SuperCollider:out_2 system:playback_2`
`jack_connect SuperCollider:in_1 system_capture_1`
`jack_connect SuperCollider:in_2 system_capture_2`
the two lines “-i”, “2” and “-o”, “2” specify the number of input and output channels used by scsynth.
you could use
sudo nano scsynthexternal.rb
to make adjustments to these two lines in the code (in fact they are both part of one long command, just spaced out to make it easier to read here).
It might be a good idea to create a backup of the file first in case of accidents!
You can use QJackctl to set up the connections to your device. SP by default will just try and connect the frsti two input and output channels as shown by the jack_connect lines.
Note, using further channels will require an increase in resources.
IN the next version of Sonic Pi a config json file may be included to make it easier to make these adjustments.
You can then try using the with_fx sound_out:
wrapper to send your putput to different channels. I think it should work.
Thank you!
This is awesome. I got it working with 6 input lines + 8 audio outputs independently and stereo pairing 4 ch with mixing live audio.
I have still something to figure out. SuperCollider outputs I got to connect to system playback automatically by adding " jack_connect SuperCollider:out_1 system:playback_1
" up to 8ch.
By adding " jack_connect SuperCollider:in_1 system_capture_1
" up to 6ch did not work at all. Every time when I start Sonic PI I need to reconnect manually SuperCollider inputs to system_capture lines on QJackctl. There must be a way to preset those connections in the source code.
IMHO you can use session to store your setup in Qjackctl no ?
Yeah, that should work. Have a look at QjackCtl and the Patchbay. Another option is to use Carla (which can not only save configuration but moreover can host audio plugins.)
I got it working with Session.
Looks like Carla does not have support for a Raspberry pi.
Only reference what I found about Carla for Raspberry was 2013 post from Jeremy:
Ah, okay, thanks for the update! (I always thought there is no real difference between Raspberry Pi and other hardware using Linux but obviously there is in some respects.)
If you interested you will probably find other/additional solutions (keyword: Jack Session Management).
Anyway - I am glad to hear that it works for you now.