sonic-pi-net / sonic-pi

Code. Music. Live.
https://sonic-pi.net
Other
10.85k stars 924 forks source link

Boot - specify only 2 channels in and out for RPi #6aa2046 kills SP for external audio card #1285

Closed rbnpi closed 6 years ago

rbnpi commented 8 years ago

the parameter -i 2 prevents jackd from opening with an external usb audio card with mono mic input and stereo output used on an RPi. Removing the -i 2 but leaving the -o 2 then it works OK. Des SP need to specify the input channels? for jackd?

I used a Sabrent USB External Stereo Sound Adapter from Amazon to test this.

samaaron commented 8 years ago

oh wow - that's interesting. I assumed that these parameters were 'max' values. For example, my Mac doesn't have 16 ins and outs, but it still works.

Does it load if you have -i 1?

rbnpi commented 8 years ago

Yes it does work with -i 1 However I think it is an absolute determination, and this might prevent a card with stereo input from initialising (not sure) so I think it best to leave it unspecified. (you can play with the command using qjackctl and an external card fitted.)

samaaron commented 8 years ago

If we don't specify it, the default is -i 8 - so I'm really not sure why that would work. Could you test it with 8 channels in?

samaaron commented 8 years ago

BTW, on a side note - do you have the scope stuff working on a RP?

rbnpi commented 8 years ago

Specifying -i 8 kills it. It seems that it tries to initialise whatever you specify, and the mono input card at least coughs when you do so and won't let jackd startup. 8 may be a maximum default, but is overridden by what you specify. I think it best to leave it unspecified. No. Haven't tried building on RPi Are the bits there to compile it on RPi?

samaaron commented 8 years ago

Which platform are you running on?

rbnpi commented 8 years ago

On Raspberry Pi

samaaron commented 8 years ago

Oh, ok, so you're updating the server code but not the GUI?

One thing to try is v3.7 of SuperCollider as that's going to be the version we use for Sonic Pi v2.11 on all platforms.

rbnpi commented 8 years ago

Yes above I was using the release 2.10 on latest raspbian on a Pi3, which had the -i2 and -o2 parameters in it. Just changing scsynthexternal.rb directly and retrying.

I looked previously at building 2.11dev on RPi but I think there are a lot of libraries missing that would have to be built from scratch, but which were available for the Linux build.

samaaron commented 8 years ago

I haven't started playing with the RP again - but if we're not able to build it with scope support, then the scope will have to be removed from the codebase - so I'm really hoping that it's going to be possible.

My plan is to release v2.11 of Sonic Pi on RP with the following upgrades:

samaaron commented 8 years ago

Also, are you referring to the parameters for jackd - this was by request from the Raspberry Pi team as it apparently stopped issues with the new kernel.

rbnpi commented 8 years ago

Yes I am. I had this sound card which I had used on the previous raspbian on my Pi3. I upgraded the SD card to the latest raspbian and SP to the 2.10 install from the raspbian repository. With the audio card inserted and selected as the default card SP didn't start. I traced the problem to the -i 2 parameter in scsynthexternal when it launched jackd. When I removed that or set it to -i 1 then it worked again. I guessed it was because the microphone input on the card was mono so jackd couldn't allocate two channels. I'm not sure why you have to specify input channels at all as SP is only using jackd for output.

samaaron commented 8 years ago

Ah ok - so scrap all I said before - that was in relationship with the new SuperCollider start parameters, not jack stuff - sorry I got confused.

The Raspberry Pi people wanted me to specify it as it appeared to fix an issue they were seeing. I'm unsure what to do now - I guess I need to go back to them - especially given that there's still audio issues with HATs.

rbnpi commented 8 years ago

Yes, I've not had any useful response to https://github.com/raspberrypi/linux/issues/1497 yet although I've referenced https://github.com/raspberrypi/linux/issues/1517 with it today. It may be related.

rbnpi commented 8 years ago

The stuttering on IQAudio and HiFiBerry amps is cured with latest kernel 4.4.y Do a sudo rp_update

samaaron commented 8 years ago

Does the latest kernel fix this issue relating to 2 channels in and out?

rbnpi commented 8 years ago

I’ll check that soon. Need to update a card on another pi first. Will let you know later today.

On 14 Jun 2016, at 09:12, Sam Aaron notifications@github.com wrote:

Does the latest kernel fix this issue relating to 2 channels in and out?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

rbnpi commented 8 years ago

Checked it now.I'm afraid the kernel upgrade does not sort this. I still have to remove the -i 2 parameter in scsynthexternal to get my usb audio card with mono input/stero output to work. This was a card that was specifically accommodated by Simon Long in the alsa support softweare so that it showed up and could be selected in the Audio Prefs utility. (SABRENT) I'm still not sure why you can't just specify the output side. SP doesn't use an external inpout channel via jackd. The PR about the stuttering has been closed. I think you may have to discuss this again with the kernel guys separately.

samaaron commented 8 years ago

@rbnpi - Just to confirm, if you omit the -i2 flag but keep -o2 does that work for you with and without external audio cards?

rbnpi commented 8 years ago

Yes I can switch between built in, IQaudio, usb SABRENT card (£5.99 Amazon) on Audio Prefs setting them as default and SP boots fine in each case with the -i 2 parameter missed out. The SABRENT card will not work at all if parameter is -i 2. However, I haven't managed to get the sound-in signal from the SABRENT card to work with SP sound_in synth yet, although I can get it working as a Mic input with Audacity, so I need to do further work on it. Incidentally the SABRENT card with a cheap mic works fine for sound input to Sonic Pi on a Mac for use with sound_in synth. I think there will be a demand for a simple sound input system to use with SP on the Pi so worth experimenting further with this.

alcluith commented 7 years ago

@samaaron @rbnpi Hi Sam and Robin,
Did you ever get the sound_in synth to work with a usb sound input? I'm trying to get this usb microphone: https://shop.pimoroni.com/products/mini-usb-microphone to work with either sound_in or live_audio on an RPi running Stretch, but no luck so far.

The microphone works fine, even when SP is running, but the sound from it isn't being passed to SP. I've had a look round the issues on the repo and on various forums but haven't managed to spot a solution yet.

Thanks!

rbnpi commented 7 years ago

Hi Claire Sound input is not activated for Raspberry Pi in scsynthexternal.rb using the built in settings. At present, the intention is that if you want to use it you should launch jackd independently BEFORE starting Sonic Pi, (do this using qjackctl, which you can run from the command line) and that you set this up for the sound input you have available. You have to make sure that the sample rate for the Mic is the same as that used for playback. (Usually 41000 for RPi), and you have to patch the output of the Mic sound to the input for scsynth. Unfortunately the Mikes are out of stoke at Pimoroni at the moment or I'd get one and try it out for you. I am now using the pisound board for sound input, which works OK with SP on the PI. This too requires you to set up the parameters using qjackctl, although once you have established them you can write them into scsynthexternal which I have done so that I can use SP headless with the card. In fact the instructions with the card suggest patching scsynthexternal to use the linux settings rather than the raspberrypi ones for connection, as this at least does the patch connections for you, and you just have to adjust the sample rate and the buffer sizes and number of periods per buffer. You may find these comments I made on blokas (pisound) site useful. https://community.blokas.io/t/pisound-first-impressions-with-sonic-pi-3/155

alcluith commented 7 years ago

Thanks, Robin!

I really appreciate the help! :-) I'll have a go with these instructions and see if I can get it to co-operate.

Will let you know how I get on.

Claire.

On Mon, Sep 18, 2017 at 10:19 PM, Robin Newman notifications@github.com wrote:

Hi Claire Sound input is not activated for Raspberry Pi in scsynthexternal.rb using the built in settings. At present, the intention is that if you want to use it you should launch jackd independently BEFORE starting Sonic Pi, (do this using qjackctl, which you can run from the command line) and that you set this up for the sound input you have available. You have to make sure that the sample rate for the Mic is the same as that used for playback. (Usually 41000 for RPi), and you have to patch the output of the Mic sound to the input for scsynth. Unfortunately the Mikes are out of stoke at Pimoroni at the moment or I'd get one and try it out for you. I am now using the pisound board for sound input, which works OK with SP on the PI. This too requires you to set up the parameters using qjackctl, althouhg once you have established them you can write them into scsynthexternal which I have done so that I can use SP headless with the card. In fact the instructions with the card suggest patching scsynthexternal to use the linux settings rather than the raspberrypi ones for connection, as this at least does the patch connections for you, and you just have to adjust the sample rate and the buffer sizes and numbet of periods per buffer. You may find these comments I made on blokas (pisound) site useful. https://community.blokas.io/t/pisound-first-impressions- with-sonic-pi-3/155

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/samaaron/sonic-pi/issues/1285#issuecomment-330359553, or mute the thread https://github.com/notifications/unsubscribe-auth/AGIdVV5XpfzlVKuTwMxeaizx1l_o5iWpks5sjt5ngaJpZM4IvDtL .

alcluith commented 7 years ago

@rbnpi Hi Robin,

Got it to work! I had a bit of a stramash the first couple of tries, but eventually set the "settings" values according to the values in scsynthexternal.rb for boot_server_raspberry_pi

jack_pid = spawn "jackd -R -p 32 -d alsa -d hw:#{audio_card} -n 3 -p 2048 -o2 -r 44100& "

fullsizerender 16

fullsizerender 18

Then started jack, started Sonic Pi, and linked up what I was hoping was the usb microphone to supercollider in the Jack connections panel: fullsizerender 17

I'll maybe have a shot at editing scsynthexternal to see if it will do it automatically later, but in the meantime you have saved my demo for tomorrow's Raspberry Jam. :-)

Thanks!

samaaron commented 7 years ago

:)

rbnpi commented 7 years ago

Great news, Hope the demo goes well. I’ll still try and get one of those mikes here. They look nice and neat and small. Robin

On 22 Sep 2017, at 13:25, Claire Quigley notifications@github.com wrote:

@rbnpi https://github.com/rbnpi Hi Robin,

Got it to work! I had a bit of a stramash the first couple of tries, but eventually set the "settings" values according to the values in scsynthexternal.rb for boot_server_raspberry_pi

jack_pid = spawn "jackd -R -p 32 -d alsa -d hw:#{audio_card} -n 3 -p 2048 -o2 -r 44100& "

alcluith commented 7 years ago

Thanks! They're definitely worth a look - the sound is not bad at all once you get it going.

samaaron commented 6 years ago

Closing this now - if anyone else is having issues with audio in on Raspberry Pi please feel free to re-open :-)

bsubbaraman commented 6 years ago

Hi all,

Thanks for such nice documentation on this @alcluith! It really helped me out, and I have my mic working. Now, I'm trying to set this up as a standalone setup. Is there a way to save the connection made between the capture device and SuperCollider? Or do this via code? I'm completely new to qjackctl, so any input is much appreciated.

Thanks!!

mbutz commented 6 years ago

Hi @bsubbaraman,

Is there a way to save the connection made between the capture device and SuperCollider?

yes, there is. Use the patchbay instead of the connection dialogue. You can save all your connections in a file and load this configuration later. See this introduction to the patchbay: http://www.rncbc.org/drupal/node/76. You can also use Carla [1] or a similar tool but I am not sure it is available on RasberryPi (although as Linux-based, it should).

  1. https://github.com/falkTX/Carla, https://kxstudio.linuxaudio.org/Applications:Carla
bsubbaraman commented 6 years ago

Thanks for these resources! Using the patchbay works great.

alcluith commented 6 years ago

Glad you found it useful, @bsubbaraman :-) And thanks for the patchbay tip @mbutz !

mbutz commented 6 years ago

Hi @bsubbaraman, hi @alcluith, de nada... there are quite a few tools to implement kind of a session management with jack. I am quite happy with the afore-mentioned Carla as it supports the integration of plugins (LADSPA or LV2 such as Calf Studio Gear) as well as to save connections settings. Having said that: If you do not need any plugins, qjackctl's patchpay is totally sufficient.