[SOLVED] How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Spanner
Established Member
Posts: 70
Joined: Mon Mar 10, 2014 8:18 pm

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by Spanner »

I'm stupid but what I would do first is record the pops and then analyse the recorded sound so that I might identify a probable origin.

crocket
Established Member
Posts: 68
Joined: Fri Mar 29, 2019 11:56 am

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by crocket »

merlyn wrote:I use Catia to manage JACK connections and Firefox appears as a JACK client called 'Audio IPC Server'. It auto-connects to the system outputs. Other than that I'm not sure what you mean about Firefox being its own patchbay.
Firefox automatically connects to system outputs. That's the problem. I want to control jack connections with my own jack patchbay.

merlyn
Established Member
Posts: 664
Joined: Thu Oct 11, 2018 4:13 pm

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by merlyn »

The Firefox JACK code was written by zam :

http://www.zamaudio.com/?p=1580

In another thread it was found that alsa_in worked without glitches using the minimum of options.

viewtopic.php?f=27&t=19610&start=15

So you could try

Code: Select all

alsa_in -j cloop -d cloop 

crocket
Established Member
Posts: 68
Joined: Fri Mar 29, 2019 11:56 am

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by crocket »

merlyn wrote:The Firefox JACK code was written by zam :

http://www.zamaudio.com/?p=1580

In another thread it was found that alsa_in worked without glitches using the minimum of options.

viewtopic.php?f=27&t=19610&start=15

So you could try

Code: Select all

alsa_in -j cloop -d cloop 
I think the problem is too much jitter coming from ALSA loopback because softwares like mpv and firefox and vivaldi feed sound signals into ALSA loopback instead of hardware capture devices. Softwares have to compete each other for CPU resource. Also, xruns between ALSA loopback and alsa_in/zita-a2j cannot be detected by either alsa_in or zita-a2j.

merlyn
Established Member
Posts: 664
Joined: Thu Oct 11, 2018 4:13 pm

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by merlyn »

After you type alsa_in it outputs 'delay = xxxx'. If the delay changes there is a glitch. To stop the delay changing leave out the options specifying the size of the buffer used for re-sampling.

crocket
Established Member
Posts: 68
Joined: Fri Mar 29, 2019 11:56 am

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by crocket »

merlyn wrote:After you type alsa_in it outputs 'delay = xxxx'. If the delay changes there is a glitch. To stop the delay changing leave out the options specifying the size of the buffer used for re-sampling.
I get no delay from alsa_in after configuring realtime cpu scheduling for rtaudio cgroup. What happens if I don't specify "-p" and "-n" for alsa_in?

Code: Select all

alsa_in -j cloop -d cloop -c 2 -p 2048 -n 3 -q 1
(Is it 256 frames per period and 3 periods per buffer? "-p" can be bytes or frames per period.)
This seems to produce much less pops than zita-a2j after configuring realtime cpu scheduling for rtaudio cgroup. The pops from alsa_in are far quieter, too.
It seems that alsa_in is better than zita-a2j at handling alsa loopback.

However, I still haven't managed to eliminate pops.
Last edited by crocket on Sun Apr 28, 2019 2:01 pm, edited 1 time in total.

merlyn
Established Member
Posts: 664
Joined: Thu Oct 11, 2018 4:13 pm

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by merlyn »

I mean the output in the terminal. Here's my output:

Code: Select all

alsa_in -j photon -d hw:2
selected sample format: 24bit - real
delay = 2968
So if you see 'delay = xxxx' in your terminal and it changes then that's the cause of the glitches and it was fixed on my system by using only -j and -d.

crocket
Established Member
Posts: 68
Joined: Fri Mar 29, 2019 11:56 am

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by crocket »

merlyn wrote:I mean the output in the terminal. Here's my output:

Code: Select all

alsa_in -j photon -d hw:2
selected sample format: 24bit - real
delay = 2968
So if you see 'delay = xxxx' in your terminal and it changes then that's the cause of the glitches and it was fixed on my system by using only -j and -d.
Delay doesn't change randomly over time whether or not I specify "-p" and "-n". What are the values of "-p" and "-n" if I don't specify them?

Why do I hear pops even if delay doesn't change?

merlyn
Established Member
Posts: 664
Joined: Thu Oct 11, 2018 4:13 pm

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by merlyn »

crocket wrote:What are the values of "-p" and "-n" if I don't specify them?
I don't know but bigger than 2048.

crocket
Established Member
Posts: 68
Joined: Fri Mar 29, 2019 11:56 am

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by crocket »

merlyn wrote:
crocket wrote:What are the values of "-p" and "-n" if I don't specify them?
I don't know but bigger than 2048.
I just read alsa_in.c. The default period_size is 1024. The default number of periods is 2.

Even with "-p 1024 -n 2", I can still hear glitches in audio. Glitches occur even if delay doesn't change.

merlyn
Established Member
Posts: 664
Joined: Thu Oct 11, 2018 4:13 pm

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by merlyn »

crocket wrote:The default period_size is 1024. The default number of periods is 2.
That's strange because the delay is much bigger when I leave options off compared to specifying a 1024 buffer.

merlyn
Established Member
Posts: 664
Joined: Thu Oct 11, 2018 4:13 pm

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by merlyn »

crocket wrote:Glitches occur even if delay doesn't change
What delay do you get? On the other thread low delays e.g. 144 weren't working.

crocket
Established Member
Posts: 68
Joined: Fri Mar 29, 2019 11:56 am

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by crocket »

merlyn wrote:
crocket wrote:Glitches occur even if delay doesn't change
What delay do you get? On the other thread low delays e.g. 144 weren't working.

Code: Select all

~> alsa_in -j cloop -d cloop -p 256 -n 3
selected sample format: 32bit
delay = 1195
delay = 769
delay = 770

merlyn
Established Member
Posts: 664
Joined: Thu Oct 11, 2018 4:13 pm

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by merlyn »

Code: Select all

~> alsa_in -j cloop -d cloop -p 256 -n 3
selected sample format: 32bit
delay = 1195
delay = 769
delay = 770
That means your delay is changing. On my output I get a delay value and it stays there. Just leave out -p and -n.

crocket
Established Member
Posts: 68
Joined: Fri Mar 29, 2019 11:56 am

Re: How can I eliminate pop sounds from alsa_in and zita-a2j working on ALSA loopback?

Post by crocket »

merlyn wrote:

Code: Select all

~> alsa_in -j cloop -d cloop -p 256 -n 3
selected sample format: 32bit
delay = 1195
delay = 769
delay = 770
That means your delay is changing. On my output I get a delay value and it stays there. Just leave out -p and -n.
The delay stabilizes after 770. It is ok for delay to change for the first few seconds.
Not specifying -p and -n is the same as "-p 1024 -n 2". I confirmed by reading delay.

Post Reply