Scarlett 18i20 gen 3 Linux - Crackling Audio

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

Moderators: khz, MattKingUSA

alex
Established Member
Posts: 7
Joined: Fri May 08, 2020 5:13 am

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by alex »

skobkin wrote:
Tue May 26, 2020 2:18 pm
@Martin79, @alex, this topic (and forum) is not about kernel building.
You should probably start with some docs about building the kernel in your distro. For example I've found some links in the Google ("ubuntu build kernel with patches"):
...
Thanks very much for the references and the heads up @skobkin. Sorry for straying off topic - I'll be more careful.

tmsmr
Established Member
Posts: 6
Joined: Wed May 27, 2020 5:45 am

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by tmsmr »

Hi @puleglot,

thanks for working on that problem. I was about to get rid of the Scarlett... You saved my (And the Scarlett's) day :D.

Model: 1235:8212 Focusrite-Novation Scarlett 4i4 USB

I just want to confirm, that the patch (Crackling playback) works for me!

- For my tests i used Audacity to create a 200 Hz tone. I heard the "pop's" in every test. With the applied patch, everything is clear now.... I know, that's not very professional - but it worked out for me. I'm only listening to music and need the microphone for online meetings. That whole ALSA/PulseAudio/JACK-topic is not what i usually work with to be honest.
- Duplex-mode is gone (Atleast with PulseAudio). I hope this will be fixed as well. In the meantime i can use another interface for the microphone.
- Is there anything i can help you with? I don't know much about professional audio, but i could familiarize myself with that topic. Or if you want me to test something: feel free to ask!

Oh, i get those "usb 5-3: Unable to change format on ep #81: already in use" messages with the changes, just like someone mentioned before. But as far as i understood, the patch for that is submitted for upstream already!?

Br,
Thomas

biaib
Posts: 1
Joined: Thu May 28, 2020 10:15 pm

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by biaib »

I applied the patch on the ubuntu focal 20.04 kernel and can confirm it works !! No more random cracklin, even at low latencies (256, 512 samples)

Thank you so much for it !

Gear: Scarlett 8i6 & Dell XPS

User avatar
skobkin
Established Member
Posts: 12
Joined: Mon Apr 13, 2020 6:58 pm
Location: Arkhangelsk, Russia
Contact:

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by skobkin »

puleglot wrote:
Wed May 20, 2020 4:44 pm
Updated patch. Added Scarlett 18i8 3rd Gen. Also slightly changed the way to get altsetting.
Tested on my 18i20 gen3 too. Works fine. No crackling. Didn't check if duplex is working on default PulseAudio setup though. Didn't see any news about fixing implicit feedback so I think that it's still not working for now.

User avatar
lilith
Established Member
Posts: 1491
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Contact:

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by lilith »

I did not follow the whole thread. Searching for

Code: Select all

retire_capture_urb: 3 callbacks suppressed
brought me here.
I just observed these kernel messages by myself when using a different USB cable. So, in my case it depends on the cable.
lapsio wrote:
Mon Mar 23, 2020 9:53 am
Oh wow. It's like almost there actually.

48kHz -i10 -o10 works:

Code: Select all


[  685.458854] usb 1-1: Re-using EP 81 in iface 2,3 @00000000efebfc96
[  685.459052] usb 1-1: Setting params for ep #81 (type 0, 12 urbs), ret=0
[  685.459321] usb 1-1: setting usb interface 1:3
[  685.459322] usb 1-1: Re-using EP 1 in iface 1,3 @000000009c0f52e0
[  685.459323] usb 1-1: Re-using EP 81 in iface 2,3 @00000000efebfc96
[  685.459494] usb 1-1: Setting params for ep #1 (type 0, 12 urbs), ret=0
[  685.459495] usb 1-1: match_endpoint_audioformats: (fmt @0000000099aa5a6c) score 1
[  685.459496] usb 1-1: match_endpoint_audioformats: (fmt @000000004456e9d2) score 1
[  685.459497] usb 1-1: match_endpoint_audioformats: (fmt @0000000069f9c2c7) score 2
[  685.459502] usb 1-1: Setting params for ep #81 (type 0, 12 urbs), ret=0
[  685.459503] usb 1-1: Starting data EP @000000009c0f52e0
[  685.459716] usb 1-1: Starting sync EP @00000000efebfc96
[  685.460934] usb 1-1: Starting data EP @00000000efebfc96

48kHz -i18 -o18 works (similar output)
48kHz -i20 -o20 works (similar output)
96kHz -i18 -o18 works (similar output)
96kHz -i10 -o10 works (similar output)
192kHz -i10 -o10 works (similar output)

capture also works properly and they indeed launch interface in selected resolutions, it's quire easy to verify since at 192kHz Scarlett 18i20 disables outputs using Custom Mix routing and that's exactly what happens when JACK is launched at 192kHz.

ALSA works
pulseaudio works

48kHz -i10 (-o20) doesn't work

Code: Select all


2020-03-23T10:27:50.011778+01:00 linux-a7l6 kernel: [  253.815529] usb 1-1: setting usb interface 2:3
2020-03-23T10:27:50.011788+01:00 linux-a7l6 kernel: [  253.815532] usb 1-1: Re-using EP 81 in iface 2,3 @00000000efebfc96
2020-03-23T10:27:50.011789+01:00 linux-a7l6 kernel: [  253.815968] usb 1-1: Setting params for ep #81 (type 0, 12 urbs), ret=0
2020-03-23T10:27:50.011789+01:00 linux-a7l6 kernel: [  253.816379] usb 1-1: setting usb interface 1:1
2020-03-23T10:27:50.011790+01:00 linux-a7l6 kernel: [  253.816381] usb 1-1: Re-using EP 1 in iface 1,1 @00000000dc3a7b64
2020-03-23T10:27:50.011790+01:00 linux-a7l6 kernel: [  253.816381] usb 1-1: Re-using EP 81 in iface 2,1 @0000000076cfa7cb
2020-03-23T10:27:50.011790+01:00 linux-a7l6 kernel: [  253.816585] usb 1-1: Setting params for ep #1 (type 0, 12 urbs), ret=0
2020-03-23T10:27:50.011791+01:00 linux-a7l6 kernel: [  253.816586] usb 1-1: match_endpoint_audioformats: (fmt @0000000099aa5a6c) score 2
2020-03-23T10:27:50.011792+01:00 linux-a7l6 kernel: [  253.816587] usb 1-1: match_endpoint_audioformats: (fmt @000000004456e9d2) score 1
2020-03-23T10:27:50.011803+01:00 linux-a7l6 kernel: [  253.816587] usb 1-1: match_endpoint_audioformats: (fmt @0000000069f9c2c7) score 1
2020-03-23T10:27:50.011805+01:00 linux-a7l6 kernel: [  253.816596] usb 1-1: Setting params for ep #81 (type 0, 12 urbs), ret=0
2020-03-23T10:27:50.011805+01:00 linux-a7l6 kernel: [  253.816596] usb 1-1: Starting data EP @00000000dc3a7b64
2020-03-23T10:27:50.011806+01:00 linux-a7l6 kernel: [  253.816827] usb 1-1: Starting sync EP @0000000076cfa7cb
2020-03-23T10:27:50.011806+01:00 linux-a7l6 kernel: [  253.818047] usb 1-1: Starting data EP @00000000efebfc96
2020-03-23T10:27:50.023766+01:00 linux-a7l6 kernel: [  253.830086] xhci_hcd 0000:00:14.0: WARN: buffer overrun event for slot 4 ep 2 on endpoint
2020-03-23T10:27:50.023788+01:00 linux-a7l6 kernel: [  253.830207] xhci_hcd 0000:00:14.0: WARN: buffer overrun event for slot 4 ep 2 on endpoint
2020-03-23T10:27:50.023789+01:00 linux-a7l6 kernel: [  253.830344] xhci_hcd 0000:00:14.0: WARN: buffer overrun event for slot 4 ep 2 on endpoint
2020-03-23T10:27:50.023789+01:00 linux-a7l6 kernel: [  253.830464] xhci_hcd 0000:00:14.0: WARN: buffer overrun event for slot 4 ep 2 on endpoint
2020-03-23T10:27:50.023790+01:00 linux-a7l6 kernel: [  253.830609] xhci_hcd 0000:00:14.0: WARN: buffer overrun event for slot 4 ep 2 on endpoint
2020-03-23T10:27:50.023791+01:00 linux-a7l6 kernel: [  253.830708] xhci_hcd 0000:00:14.0: WARN: buffer overrun event for slot 4 ep 2 on endpoint
2020-03-23T10:27:50.027764+01:00 linux-a7l6 kernel: [  253.830833] xhci_hcd 0000:00:14.0: WARN: buffer overrun event for slot 4 ep 2 on endpoint
2020-03-23T10:27:50.027794+01:00 linux-a7l6 kernel: [  253.830963] xhci_hcd 0000:00:14.0: WARN: buffer overrun event for slot 4 ep 2 on endpoint
2020-03-23T10:27:50.027796+01:00 linux-a7l6 kernel: [  253.830966] retire_capture_urb: 7574 callbacks suppressed
2020-03-23T10:27:50.027796+01:00 linux-a7l6 kernel: [  253.830967] usb 1-1: frame 0 active: -75
2020-03-23T10:27:50.027797+01:00 linux-a7l6 kernel: [  253.830969] usb 1-1: frame 1 active: -75
2020-03-23T10:27:50.027802+01:00 linux-a7l6 kernel: [  253.830970] usb 1-1: frame 2 active: -75
2020-03-23T10:27:50.027803+01:00 linux-a7l6 kernel: [  253.830971] usb 1-1: frame 3 active: -75
2020-03-23T10:27:50.027803+01:00 linux-a7l6 kernel: [  253.830972] usb 1-1: frame 4 active: -75
2020-03-23T10:27:50.027804+01:00 linux-a7l6 kernel: [  253.830973] usb 1-1: frame 5 active: -75
2020-03-23T10:27:50.027805+01:00 linux-a7l6 kernel: [  253.830975] usb 1-1: frame 6 active: -75
2020-03-23T10:27:50.027805+01:00 linux-a7l6 kernel: [  253.830976] usb 1-1: frame 7 active: -75
2020-03-23T10:27:50.027805+01:00 linux-a7l6 kernel: [  253.831085] xhci_hcd 0000:00:14.0: WARN: buffer overrun event for slot 4 ep 2 on endpoint
2020-03-23T10:27:50.027806+01:00 linux-a7l6 kernel: [  253.831207] xhci_hcd 0000:00:14.0: WARN: buffer overrun event for slot 4 ep 2 on endpoint
2020-03-23T10:27:50.027806+01:00 linux-a7l6 kernel: [  253.831333] xhci_hcd 0000:00:14.0: WARN: buffer overrun event for slot 4 ep 2 on endpoint

48kHz -o10 (-i20) doesn't work

Code: Select all


[  336.795120] usb 1-1: setting usb interface 2:1
[  336.795123] usb 1-1: Re-using EP 81 in iface 2,1 @0000000076cfa7cb
[  336.795518] usb 1-1: Setting params for ep #81 (type 0, 12 urbs), ret=0
[  336.795818] usb 1-1: setting usb interface 1:3
[  336.795819] usb 1-1: Re-using EP 1 in iface 1,3 @000000009c0f52e0
[  336.795820] usb 1-1: Re-using EP 81 in iface 2,3 @00000000efebfc96
[  336.796016] usb 1-1: Setting params for ep #1 (type 0, 12 urbs), ret=0
[  336.796017] usb 1-1: match_endpoint_audioformats: (fmt @0000000099aa5a6c) score 1
[  336.796017] usb 1-1: match_endpoint_audioformats: (fmt @000000004456e9d2) score 1
[  336.796018] usb 1-1: match_endpoint_audioformats: (fmt @0000000069f9c2c7) score 2
[  336.796026] usb 1-1: Setting params for ep #81 (type 0, 12 urbs), ret=0
[  336.796027] usb 1-1: Starting data EP @000000009c0f52e0
[  336.796258] usb 1-1: Starting sync EP @00000000efebfc96
[  336.797572] usb 1-1: Starting data EP @0000000076cfa7cb
[  336.974386] usb 1-1: Starting data EP @000000009c0f52e0
[  336.974833] usb 1-1: Starting sync EP @00000000efebfc96
[  336.974921] usb 1-1: Starting data EP @0000000076cfa7cb
[  337.150445] usb 1-1: Starting data EP @000000009c0f52e0
[  337.150791] usb 1-1: Starting sync EP @00000000efebfc96
[  337.150857] usb 1-1: Starting data EP @0000000076cfa7cb
[  337.326478] usb 1-1: Starting data EP @000000009c0f52e0
[  337.326937] usb 1-1: Starting sync EP @00000000efebfc96
[  337.327045] usb 1-1: Starting data EP @0000000076cfa7cb
[  337.502444] usb 1-1: Starting data EP @000000009c0f52e0
[  337.502854] usb 1-1: Starting sync EP @00000000efebfc96
[  337.502949] usb 1-1: Starting data EP @0000000076cfa7cb
[  337.678431] usb 1-1: Starting data EP @000000009c0f52e0
[  337.678861] usb 1-1: Starting sync EP @00000000efebfc96
[  337.678964] usb 1-1: Starting data EP @0000000076cfa7cb
[  337.854411] usb 1-1: Starting data EP @000000009c0f52e0
[  337.854757] usb 1-1: Starting sync EP @00000000efebfc96
[  337.854814] usb 1-1: Starting data EP @0000000076cfa7cb

But uh. Idk. I mean if I didn't test that before patching I'd probably assume mixed i/o configs are just not supposed to work because like... I don't really see any use case for that realistically. tbh I don't really see any reason to launch interface with less than max available inputs/outputs in general as long as it works properly with full i/o... I believe raw ALSA and pulseaudio do 10/10 at 48kHz just because in such config they can map channels to 7.1 system dictionary more easily. That's the only reasoning I can see behind that.

For me it basically works. I'll test for few days again to search for some audible side effects/crackling etc but I guess I tested most of it already.

The only side effect I see is that sometimes Scarlett just crashes physically and disconnects when JACK is restarting it to change sample rate but it kinda also happened randomly before patching so I guess that's just how this unit operates sometimes. Also it's rare and switching it off/on solves the problem so w.e.

Code: Select all


2020-03-23T10:37:33.823824+01:00 linux-a7l6 kernel: [  837.387140] usb 1-1: setting usb interface 2:1
2020-03-23T10:37:33.823837+01:00 linux-a7l6 kernel: [  837.387142] usb 1-1: Re-using EP 81 in iface 2,1 @000000008c495897
2020-03-23T10:37:33.823838+01:00 linux-a7l6 kernel: [  837.387433] usb 1-1: Setting params for ep #81 (type 0, 12 urbs), ret=0
2020-03-23T10:37:33.823838+01:00 linux-a7l6 kernel: [  837.387777] usb 1-1: setting usb interface 1:1
2020-03-23T10:37:33.823838+01:00 linux-a7l6 kernel: [  837.387778] usb 1-1: Re-using EP 1 in iface 1,1 @00000000683d7406
2020-03-23T10:37:33.823839+01:00 linux-a7l6 kernel: [  837.387779] usb 1-1: Re-using EP 81 in iface 2,1 @000000008c495897
2020-03-23T10:37:33.823866+01:00 linux-a7l6 kernel: [  837.387982] usb 1-1: Setting params for ep #1 (type 0, 12 urbs), ret=0
2020-03-23T10:37:33.823867+01:00 linux-a7l6 kernel: [  837.387983] usb 1-1: match_endpoint_audioformats: (fmt @000000000c0318a1) score 2
2020-03-23T10:37:33.823868+01:00 linux-a7l6 kernel: [  837.387984] usb 1-1: match_endpoint_audioformats: (fmt @00000000dfbd255e) score 1
2020-03-23T10:37:33.823869+01:00 linux-a7l6 kernel: [  837.387984] usb 1-1: match_endpoint_audioformats: (fmt @000000002ca408d6) score 1
2020-03-23T10:37:33.823869+01:00 linux-a7l6 kernel: [  837.387991] usb 1-1: Setting params for ep #81 (type 0, 12 urbs), ret=0
2020-03-23T10:37:33.823870+01:00 linux-a7l6 kernel: [  837.387991] usb 1-1: Starting data EP @00000000683d7406
2020-03-23T10:37:33.823870+01:00 linux-a7l6 kernel: [  837.388209] usb 1-1: Starting sync EP @000000008c495897
2020-03-23T10:37:33.823871+01:00 linux-a7l6 kernel: [  837.389214] usb usb1-port1: disabled by hub (EMI?), re-enabling...
2020-03-23T10:37:33.823871+01:00 linux-a7l6 kernel: [  837.389216] usb 1-1: USB disconnect, device number 6


User avatar
skobkin
Established Member
Posts: 12
Joined: Mon Apr 13, 2020 6:58 pm
Location: Arkhangelsk, Russia
Contact:

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by skobkin »

lilith wrote:
Mon Jun 01, 2020 6:01 pm
So, in my case it depends on the cable.
Without the patch I had different amount of crackling sounds per minute on different cables or when using different ports.

User avatar
lilith
Established Member
Posts: 1491
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Contact:

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by lilith »

skobkin wrote:
Mon Jun 01, 2020 6:07 pm
lilith wrote:
Mon Jun 01, 2020 6:01 pm
So, in my case it depends on the cable.
Without the patch I had different amount of crackling sounds per minute on different cables or when using different ports.
Both of the cables I used where USB 2.0 certified. That's really strange. I thought a cable works or it does not, but obviously there is something in between even with digital signals.

lapsio
Established Member
Posts: 39
Joined: Thu Sep 01, 2016 7:34 am

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by lapsio »

What's current status of this patch in mainline ALSA? It's nice that it works in patched kernels but I still need to do weird hacks with netJACK and passing through USB to VM running patched kernel because VMWare Workstation and DisplayLink EVDI modules don't really want to compile for me on patched kernel thus I can't use it on bare metal :C

I think at this point more than enough people confirmed those fixes work properly

User avatar
skobkin
Established Member
Posts: 12
Joined: Mon Apr 13, 2020 6:58 pm
Location: Arkhangelsk, Russia
Contact:

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by skobkin »

lapsio wrote:
Tue Jun 09, 2020 7:37 pm
I think at this point more than enough people confirmed those fixes work properly
They didn't. Applying that patch breaks audio duplex in ALSA and PulseAudio. I don't think it'll end in upstream before implicit feedback problem is solved too.

puleglot
Established Member
Posts: 113
Joined: Thu Jan 23, 2020 3:14 pm

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by puleglot »

Also I doubt that 18i8 will work correctly with my patch. I should probably add additional filtering of sample rates on the output interface for this device.

zinigor
Established Member
Posts: 3
Joined: Wed Apr 29, 2020 4:43 pm

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by zinigor »

I was using the patch with totally no problem on Ubuntu 20.04 with a Linux 5.6.x-xanmod kernel, but since upgrading to a 5.7.x-xanmod, applying the same patch, I get crackling in "batches". The sound works perfectly, but then every once in a while, like every 5 minutes, there's a burst of crackling sound for about 10-20 seconds.

I don't get anything in the kernel log, or in systemd logs. Is there any way I can help debug the problem? I'm open to testing different patches, adding debug output, etc. I just don't know how to do it :)

zinigor
Established Member
Posts: 3
Joined: Wed Apr 29, 2020 4:43 pm

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by zinigor »

As a follow-up to my previous message I'd like to point out one strange find. The crackling problem is sometimes worse depending on the boot, I don't know why. Today I decided to try to enable `dev_dbg` in some of the relevant kernel files, namely `pcm.c`, `endpoint.c` and some others. Doing that I noticed a strange thing. When I open pavucontrol (I'm using pulseaudio for sound), the feedback endpoint gets reused for some reason:

Code: Select all

[10646.054079] usb 5-1.7: Re-using EP 81 in iface 1,6 @00000000c7975859
[10646.055988] usb 5-1.7: Setting params for ep #81 (type 0, 12 urbs), ret=0
[10646.056007] usb 5-1.7: Starting data EP @00000000c7975859
[10646.195967] usb 5-1.6: reset high-speed USB device number 6 using xhci_hcd
[10646.513724] usb 5-1.6: Re-using EP 86 in iface 3,4 @00000000cca07550
[10647.647916] usb 5-1.6: Setting params for ep #86 (type 0, 12 urbs), ret=0
[10647.647942] usb 5-1.6: Starting data EP @00000000cca07550
[10647.710022] usb 5-1.5: Re-using EP 8 in iface 3,1 @0000000088f0fd83
[10647.710564] usb 5-1.5: Setting params for ep #8 (type 0, 3 urbs), ret=0
[10647.710566] usb 5-1.5: Starting data EP @0000000088f0fd83
[10648.254231] usb 5-1.5: Re-using EP 7 in iface 2,1 @0000000069496b91
[10648.255074] usb 5-1.5: Setting params for ep #7 (type 0, 3 urbs), ret=0
[10648.255080] usb 5-1.5: Starting data EP @0000000069496b91
[10648.404516] usb 5-1.5: Re-using EP 81 in iface 1,1 @00000000befb1040
[10648.405339] usb 5-1.5: Setting params for ep #81 (type 0, 12 urbs), ret=0
[10648.405414] usb 5-1.5: Starting data EP @00000000befb1040
When this happens, the sound stops for a couple of seconds and comes back without any crackling. As soon as I close pavucontrol, crackling comes back. So I'm able to keep the sound clean by not closing pavucontrol.

escuta
Established Member
Posts: 3
Joined: Thu Jan 30, 2020 4:52 pm

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by escuta »

Hi @puleglot,

Many thanks for the patch. I'm trying to use it with a realtime kernel for the Raspberry Pi 4 which I originally built and installed with these instructions: https://lemariva.com/blog/2019/09/raspb ... mance-test

I'm having trouble using the patch. The following dry run with --ignore-whitespace and --fuzz produces failure notices:

Code: Select all

iain@samsung:~/rpi-kernel/linux$ patch --verbose --dry-run --ignore-whitespace --fuzz 3 -p1 < ~/myproject/scarlett_gen3_implicit_fb.txt
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
|index bd258f1ec2dd..5e2508b9173a 100644
|--- a/sound/usb/pcm.c
|+++ b/sound/usb/pcm.c
--------------------------
checking file sound/usb/pcm.c
Using Plan A...
Hunk #1 succeeded at 365 with fuzz 3.
Hunk #2 FAILED at 393.
1 out of 2 hunks FAILED
done
I've attached the pcm.c file here:
pcm.c
Any advice greatly appreciated!

Iain
You do not have the required permissions to view the files attached to this post.

tkcomposer
Established Member
Posts: 12
Joined: Wed Feb 05, 2020 4:44 am

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by tkcomposer »

@puleglot , thanks for the patch! It works well for my 18i20 3rd gen (patched over 5.7.9-arch1-1).

I assume you plan to submit this patch to the upstream, correct?

ezemtsov
Posts: 2
Joined: Tue Aug 11, 2020 7:00 pm

Re: Scarlett 18i20 gen 3 Linux - Crackling Audio

Post by ezemtsov »

@puleglot,

Thanks for the effort, the patch fixed the artifacts.
I'm using Musnix with your patch on top of 5.6rt kernel.

Though I wasn't able to make it work with Jack2, only with Bitwig using ALSA directly.
Jack starts but doesn't work properly, shows errors and corrupts the audio stream.

Post Reply