Focusrite Scarlett 2i2 on Linux help!

Talk about your MIDI interfaces, microphones, keyboards...

Moderators: MattKingUSA, khz

CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Focusrite Scarlett 2i2 on Linux help!

Post by CrocoDuck »

Gulliver wrote:
CrocoDuck wrote:

Code: Select all

aplay -l
arecord -l
amidi -l

Code: Select all

fg@fg-pc:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: MID [HDA Intel MID], device 0: 92HD81B1X5 Analog [92HD81B1X5 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: MID [HDA Intel MID], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: USB [Scarlett 2i2 USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
fg@fg-pc:~$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: MID [HDA Intel MID], device 0: 92HD81B1X5 Analog [92HD81B1X5 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: USB [Scarlett 2i2 USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
fg@fg-pc:~$ amidi -l
Alright, this is very good. Your Scarlett is everywhere where it should be!

Now, have a look at how it is presented:

card 1: USB [Scarlett 2i2 USB], device 0: USB Audio [USB Audio]

Which means that ALSA has numerated this device as hw:1,0

You can use the ALSA device name (hw:1,0) everywhere you need to designate this device.
Gulliver wrote:I tried to create the session with ALSA and it worked.
OK, that's good. Now, it is worth to have a look at JACK in more detail, even if maybe you will end up not using it. The reason is that it allow us to expose not optimal audio configuration in your system and fix it. All you do with qjackctl can be done from the command line, and we can see what is being actually done by the GUI when looking at the output of this command:

Code: Select all

cat .jackdrc
This is the easiest way to share around your qjackctl setup (the last one you run). Let's have a look at it.
Gulliver
Established Member
Posts: 39
Joined: Sun Jan 08, 2017 7:07 pm

Re: Focusrite Scarlett 2i2 on Linux help!

Post by Gulliver »

CrocoDuck wrote:
Gulliver wrote:
CrocoDuck wrote:

Code: Select all

aplay -l
arecord -l
amidi -l

Code: Select all

fg@fg-pc:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: MID [HDA Intel MID], device 0: 92HD81B1X5 Analog [92HD81B1X5 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: MID [HDA Intel MID], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: USB [Scarlett 2i2 USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
fg@fg-pc:~$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: MID [HDA Intel MID], device 0: 92HD81B1X5 Analog [92HD81B1X5 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: USB [Scarlett 2i2 USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
fg@fg-pc:~$ amidi -l
Alright, this is very good. Your Scarlett is everywhere where it should be!

Now, have a look at how it is presented:

card 1: USB [Scarlett 2i2 USB], device 0: USB Audio [USB Audio]

Which means that ALSA has numerated this device as hw:1,0

You can use the ALSA device name (hw:1,0) everywhere you need to designate this device.
Gulliver wrote:I tried to create the session with ALSA and it worked.
OK, that's good. Now, it is worth to have a look at JACK in more detail, even if maybe you will end up not using it. The reason is that it allow us to expose not optimal audio configuration in your system and fix it. All you do with qjackctl can be done from the command line, and we can see what is being actually done by the GUI when looking at the output of this command:

Code: Select all

cat .jackdrc
This is the easiest way to share around your qjackctl setup (the last one you run). Let's have a look at it.

Code: Select all

/usr/bin/jackd -dalsa -dhw:USB -r48000 -p1024 -n2
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Focusrite Scarlett 2i2 on Linux help!

Post by CrocoDuck »

Ok, looks alright. Now, what happens if you try to run that in the terminal? Copy and paste here (you can use CTRL + C to exit the process).
Gulliver
Established Member
Posts: 39
Joined: Sun Jan 08, 2017 7:07 pm

Re: Focusrite Scarlett 2i2 on Linux help!

Post by Gulliver »

CrocoDuck wrote:Ok, looks alright. Now, what happens if you try to run that in the terminal? Copy and paste here (you can use CTRL + C to exit the process).
Run what in the terminal?
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Focusrite Scarlett 2i2 on Linux help!

Post by CrocoDuck »

Gulliver wrote:
Run what in the terminal?
Sorry, this:

Code: Select all

/usr/bin/jackd -dalsa -dhw:USB -r48000 -p1024 -n2
which you found above is a command you can enter in the terminal. It will start jackd, the JACK daemon, with the same parameters you configured with qjackctl, but from the command line.

We are doing this as a quick way to assess audio related permissions on your system, the command output will show us if anything is wrong. Appropriate permissions are also needed to properly configure audio related stuff for wine. Let's have a look also at the output of this:

Code: Select all

groups
Gulliver
Established Member
Posts: 39
Joined: Sun Jan 08, 2017 7:07 pm

Re: Focusrite Scarlett 2i2 on Linux help!

Post by Gulliver »

CrocoDuck wrote:
Gulliver wrote:
Run what in the terminal?
Sorry, this:

Code: Select all

/usr/bin/jackd -dalsa -dhw:USB -r48000 -p1024 -n2
which you found above is a command you can enter in the terminal. It will start jackd, the JACK daemon, with the same parameters you configured with qjackctl, but from the command line.

We are doing this as a quick way to assess audio related permissions on your system, the command output will show us if anything is wrong. Appropriate permissions are also needed to properly configure audio related stuff for wine. Let's have a look also at the output of this:

Code: Select all

groups
I see. Here's the output:

Code: Select all

jackdmp 1.9.11
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2014 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
Cannot create RT messagebuffer thread: Operation not permitted (1)
Retrying messagebuffer thread without RT scheduling
Messagebuffer not realtime; consider enabling RT scheduling for user
no message buffer overruns
Cannot create RT messagebuffer thread: Operation not permitted (1)
Retrying messagebuffer thread without RT scheduling
Messagebuffer not realtime; consider enabling RT scheduling for user
no message buffer overruns
Cannot create RT messagebuffer thread: Operation not permitted (1)
Retrying messagebuffer thread without RT scheduling
Messagebuffer not realtime; consider enabling RT scheduling for user
no message buffer overruns
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Cannot lock down 82274202 byte memory area (Cannot allocate memory)
audio_reservation_init
Acquire audio card Audio1
creating alsa driver ... hw:USB|hw:USB|1024|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
Cannot use real-time scheduling (RR/10)(1: Operation not permitted)
AcquireSelfRealTime error
for groups:

Code: Select all

xy adm cdrom sudo dip plugdev lpadmin sambashare
digikwondo
Established Member
Posts: 10
Joined: Wed Jun 07, 2017 11:06 pm

Re: Focusrite Scarlett 2i2 on Linux help!

Post by digikwondo »

Code: Select all

Cannot use real-time scheduling (RR/10)(1: Operation not permitted)
are you using a real time kernel ?

run this command : uname -a


if not try un-tick the "realtime" setting in your jack configuration. (might lead to higher latency in the end...)

also your user is missing from the "audio" group. you need to add your user to this group and logout/login for changes to take effect.

hope this helps
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Focusrite Scarlett 2i2 on Linux help!

Post by CrocoDuck »

Gulliver wrote:
CrocoDuck wrote:
Gulliver wrote:
Run what in the terminal?
Sorry, this:

Code: Select all

/usr/bin/jackd -dalsa -dhw:USB -r48000 -p1024 -n2
which you found above is a command you can enter in the terminal. It will start jackd, the JACK daemon, with the same parameters you configured with qjackctl, but from the command line.

We are doing this as a quick way to assess audio related permissions on your system, the command output will show us if anything is wrong. Appropriate permissions are also needed to properly configure audio related stuff for wine. Let's have a look also at the output of this:

Code: Select all

groups
I see. Here's the output:

Code: Select all

jackdmp 1.9.11
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2014 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
Cannot create RT messagebuffer thread: Operation not permitted (1)
Retrying messagebuffer thread without RT scheduling
Messagebuffer not realtime; consider enabling RT scheduling for user
no message buffer overruns
Cannot create RT messagebuffer thread: Operation not permitted (1)
Retrying messagebuffer thread without RT scheduling
Messagebuffer not realtime; consider enabling RT scheduling for user
no message buffer overruns
Cannot create RT messagebuffer thread: Operation not permitted (1)
Retrying messagebuffer thread without RT scheduling
Messagebuffer not realtime; consider enabling RT scheduling for user
no message buffer overruns
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Cannot lock down 82274202 byte memory area (Cannot allocate memory)
audio_reservation_init
Acquire audio card Audio1
creating alsa driver ... hw:USB|hw:USB|1024|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
Cannot use real-time scheduling (RR/10)(1: Operation not permitted)
AcquireSelfRealTime error
for groups:

Code: Select all

xy adm cdrom sudo dip plugdev lpadmin sambashare
There we go! Your user doesn't have the appropriate permission to do pro audio stuff! Now we are gonna enable all of them.

A comment:
digikwondo wrote:are you using a real time kernel ?
There is no need for a realtime or patched kernel to run jack with RT priority: it as a matter of permissions. See here. But we can still have a look at the kernel and see what it is.

So, let's start adding your user to the audio group:

Code: Select all

sudo usermod -aG audio <your_user_name>
Where you should put your user name in there, for example (assuming your user name is gulliver):

Code: Select all

sudo usermod -aG audio gulliver
Do the same with the lp and sys groups:

Code: Select all

sudo usermod -aG lp <your_user_name>
sudo usermod -aG sys <your_user_name>
These are not needed for audio, but they are needed to have wine having access to all audio devices.

This user groups thing might seem very quirky, but it is one of the things that makes Linux secure: you allow only selected users to have access to selected devices, up to the degree you decide.

These changes will be effective after logging out and back in, or after rebooting.
digikwondo
Established Member
Posts: 10
Joined: Wed Jun 07, 2017 11:06 pm

Re: Focusrite Scarlett 2i2 on Linux help!

Post by digikwondo »

@CrocoDuck

thanks for the clarification :)
Gulliver
Established Member
Posts: 39
Joined: Sun Jan 08, 2017 7:07 pm

Re: Focusrite Scarlett 2i2 on Linux help!

Post by Gulliver »

CrocoDuck wrote:
Gulliver wrote:
CrocoDuck wrote:
So, let's start adding your user to the audio group:

Code: Select all

sudo usermod -aG audio <your_user_name>
Where you should put your user name in there, for example (assuming your user name is gulliver):

Code: Select all

sudo usermod -aG audio gulliver
Do the same with the lp and sys groups:

Code: Select all

sudo usermod -aG lp <your_user_name>
sudo usermod -aG sys <your_user_name>
These are not needed for audio, but they are needed to have wine having access to all audio devices.

This user groups thing might seem very quirky, but it is one of the things that makes Linux secure: you allow only selected users to have access to selected devices, up to the degree you decide.

These changes will be effective after logging out and back in, or after rebooting.
Done, what's next?
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Focusrite Scarlett 2i2 on Linux help!

Post by CrocoDuck »

Gulliver wrote:Done, what's next?
I would suggest to have a go running JACK from the command line again and see if we can start it. Just to see how the access to audio devices works now and see whether that points out some more configuration issues. Then, we might look at some more audio optimization and finally we can try to see how our wine application works. But one step at a time!
Gulliver
Established Member
Posts: 39
Joined: Sun Jan 08, 2017 7:07 pm

Re: Focusrite Scarlett 2i2 on Linux help!

Post by Gulliver »

CrocoDuck wrote:
Gulliver wrote:Done, what's next?
I would suggest to have a go running JACK from the command line again and see if we can start it. Just to see how the access to audio devices works now and see whether that points out some more configuration issues. Then, we might look at some more audio optimization and finally we can try to see how our wine application works. But one step at a time!
Ok, so this the code I should be running?

Code: Select all

cat .jackdrc
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Focusrite Scarlett 2i2 on Linux help!

Post by CrocoDuck »

Gulliver wrote:
Ok, so this the code I should be running?

Code: Select all

cat .jackdrc
That will return the parameter with which JACK was launched the last time by qjackctl. For example, when I run it I get:

Code: Select all

/usr/bin/jackd -P70 -t5000 -dalsa -r96000 -p4096 -n3 -D -Chw:USB,0 -Phw:USB,0
Now, if I copy and paste the line above in the terminal and press enter I launch JACK with those exact paramters:

Code: Select all

[crocoduck@arch ~]$ cat .jackdrc
/usr/bin/jackd -P70 -t5000 -dalsa -r96000 -p4096 -n3 -D -Chw:USB,0 -Phw:USB,0
[crocoduck@arch ~]$ /usr/bin/jackd -P70 -t5000 -dalsa -r96000 -p4096 -n3 -D -Chw:USB,0 -Phw:USB,0
jackdmp 1.9.10
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2014 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
no message buffer overruns
no message buffer overruns
no message buffer overruns
JACK server starting in realtime mode with priority 70
self-connect-mode is "Don't restrict self connect requests"
audio_reservation_init
Acquire audio card Audio2
creating alsa driver ... hw:USB,0|hw:USB,0|4096|3|96000|0|0|nomon|swmeter|-|32bit
configuring for 96000Hz, period = 4096 frames (42.7 ms), buffer = 3 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 3 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 3 periods for playback
That's sort of how the command line looks when JACK is started correctly. You can then exit with CTRL + C.

If JACK fails to start in the prompt above we will see errors.

We are doing this to complete permissions troubleshooting: although we added your user to the groups we need, there might be still something to edit in conf files. This will point out where to look.

Maybe I am guiding you through some old school troubleshooting, but I hope you will gain enough knowledge of Linux audio through this so to become independent :wink:
Gulliver
Established Member
Posts: 39
Joined: Sun Jan 08, 2017 7:07 pm

Re: Focusrite Scarlett 2i2 on Linux help!

Post by Gulliver »

CrocoDuck wrote:
Gulliver wrote:
Ok, so this the code I should be running?

Code: Select all

cat .jackdrc
That will return the parameter with which JACK was launched the last time by qjackctl. For example, when I run it I get:

Code: Select all

/usr/bin/jackd -P70 -t5000 -dalsa -r96000 -p4096 -n3 -D -Chw:USB,0 -Phw:USB,0
Now, if I copy and paste the line above in the terminal and press enter I launch JACK with those exact paramters:

Code: Select all

[crocoduck@arch ~]$ cat .jackdrc
/usr/bin/jackd -P70 -t5000 -dalsa -r96000 -p4096 -n3 -D -Chw:USB,0 -Phw:USB,0
[crocoduck@arch ~]$ /usr/bin/jackd -P70 -t5000 -dalsa -r96000 -p4096 -n3 -D -Chw:USB,0 -Phw:USB,0
jackdmp 1.9.10
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2014 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
no message buffer overruns
no message buffer overruns
no message buffer overruns
JACK server starting in realtime mode with priority 70
self-connect-mode is "Don't restrict self connect requests"
audio_reservation_init
Acquire audio card Audio2
creating alsa driver ... hw:USB,0|hw:USB,0|4096|3|96000|0|0|nomon|swmeter|-|32bit
configuring for 96000Hz, period = 4096 frames (42.7 ms), buffer = 3 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 3 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 3 periods for playback
That's sort of how the command line looks when JACK is started correctly. You can then exit with CTRL + C.

If JACK fails to start in the prompt above we will see errors.

We are doing this to complete permissions troubleshooting: although we added your user to the groups we need, there might be still something to edit in conf files. This will point out where to look.

Maybe I am guiding you through some old school troubleshooting, but I hope you will gain enough knowledge of Linux audio through this so to become independent :wink:
Hope I got it correctly:

Code: Select all

me@me-pc:~$ cat .jackdrc
/usr/bin/jackd -dalsa -dhw:USB -r48000 -p1024 -n2
me@me-pc:~$ 
me@me-pc:~$ /usr/bin/jackd -dalsa -dhw:USB -r48000 -p1024 -n2
jackdmp 1.9.11
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2014 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
no message buffer overruns
no message buffer overruns
no message buffer overruns
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
audio_reservation_init
Acquire audio card Audio1
creating alsa driver ... hw:USB|hw:USB|1024|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Focusrite Scarlett 2i2 on Linux help!

Post by CrocoDuck »

OK, looks like JACK is starting, but perhaps not in realtime mode. You can try to set realtime by launching qjackctl and clicking setup. TIck Realtime under the Driver dropdown menu. Save your profile and try to start JACK. Report any eventual errors. Once this is sorted we will go back to the Wine audio device selector.
Post Reply