Minimizing Latency (Am I missing something or am I screwed?)

Still new to all of this? Feel free to post in any of the subforums on this site, but in this subforum newbie questions are especially encouraged!

Moderators: MattKingUSA, khz

Post Reply
User avatar
NLHybrid
Established Member
Posts: 5
Joined: Sun Apr 26, 2020 12:57 pm

Minimizing Latency (Am I missing something or am I screwed?)

Post by NLHybrid »

Before I spew my frustrations, let me give some background:

I am completely new to all of this linux audio stuff(not new to linux but definitely not intermediate level)..I just started tinkering with this 2 days ago and I have literally spent over 15 hours, fumbling my way to this sad point on my own. I may have done some things incorrect or followed deprecated instructions as I tried to scour reputable sources before coming here. I'm actually considering just scrapping it all and switching to some audio-specific distro but I need to exhaust my options before I go that path (I'm stubborn like that).

Equipment
NI Komplete Audio 2 USB Interface (newly purchased)
Ryzen 5 2600 (3.4 GHz, 6core)
2x8gb-2666MHz DDR4 Ram (Corsair Vengeance LPX)
MSI Arctic Mortar B450m Mobo (space for 1more pci card)
MSI AMD RX580 GPU
Sarmonic Lavalier XLavMic-C (XLR->KA2 Interface Input1 with phantom power on) (newly purchased)
-I picked a lav mic because I have a lot of background noise at my apartment, my thinking is that this will help keep the noise area limited to near my mouth and I don't have much space around my desk for a condenser mic.
Electric guitar-->KA2 Interface input2
Boss Katana MkII 212 (has ability to interface with pc, but I haven't tried it for linux/jack yet but...baby steps)


Current System Config

Desktop Environment: Manjaro-GNOME 3.36.1
Kernel: 5.6.4 Rt

How do I currently use my system?:
I listen to the sound through the internal soundcard (realtek alc898) with either
A line out to some edifier 1700BT speakers or
B usb bluetooth dongle to some bluetooth earphones (I think using jack kills this option....I may have to get some headphones to use with the monitor out in my interface, it has a host/input blend knob)

What are my goals of this endeavour?
1) To input mic audio for desktop/web applications such as telegram, discord, google meetups(webmeetings), LINE(a mobile/desktop chat messenger program)
2) For mic input when I am recording myself speaking while I presentations/lectures for online classes I am teaching.
3) Another outlet for playing guitar, I like to tinker with effects and stuff. I want to monitor my sound after effects and processing without being with the horrible latency delay.
4) Recording backing tracks to help myself practice.
5) Eventually maybe make more songs and stuff but I need to get more familiar with the other instrument programs out there like drums and synths before I can get there....

---------------------------------------------
What have I done so far?

1) Follow this guide https://forum.manjaro.org/t/how-to-repl ... riend/2086
I picked Cadence over QJackctl

2) After installing all the pulseaudio stuff, I wanted to test. With my guitar through the interface, I simply patched (in Claudia) my hardware input box to my system playback box so I could hear it through my speakers.

3) Success! But the most bittersweet. There was sound but at buffer size: 2048 and sample rate: 48000 kHz, my latency is at 42 ms. If I reduce the buffer size any more the xruns just continuously come and it just loses composure. I can't accept that this is my lowest latency given my setup, I can't play either with that bad delay. I bought the KA 2 interface based on this review https://www.youtube.com/watch?v=mA7_fcdx12I, and this guy could get 10ms with a laptop...why can't I beat that? I wasn't running any major things through jack other than just the guitar signal straight to speakers and I had some firefox windows (no videos) in the background.

4) So...I go down the rabbit hole of which it feels there is no end. I first used realtimeconfigquickscan and found that I failed some things. Then, before changing anything, I downloaded Linux-RT, why? I just saw bits and pieces of info that told me it wasn't a bad idea.

5) I addressed the realtimeconfigquickscan issues, I added my profile to the audio group and then made /dev/hpet and /dev/rtc accessible.
7) Everything passed in realtimeconfigquickscan but no improvement whatsoever in jack.

Now, I'm currently going through the steps in figuring out how to change RTPRIO for my interface, my soundcard, and jackdbus. I downloaded rtirq and added "threadirqs" to my /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT line as per https://wiki.linuxaudio.org/wiki/system_configuration. Now, I'm really not sure what to do.....do I use rtirq or do I manually change the rtprio for each irq I find the devices on?

Secondly, when trying to find the IRQ# for my Interface(more specifically the usb controller)....I confirmed it through the lsusb -v and lspci -v. It is 100% IRQ 30.....yet when I go to /proc/interrupts....there is an IRQ29 and IRQ31 but no 30, where could it be?!! I made sure the interface was running(the usb light was on and jack was running). I have no idea how to overcome that obstacle yet :cry: On the bright side, I was able to identify the IRQ for my soundcard and modify jackdbus's priority to 95 in the engine settings of cadence.

Can someone please throw some advice my way on how to find that usb irq and properly adjust the priorities and tell me what I should try next? Should I just stop here and start over using a lower-latency kernel or change to an XFCE DE or AVlinux? Please, my brain is fried at this point :lol:

RESOLVED: I just can't set my my output in jack to use the soundcard(the analog portion at least...), only my audio interface. I was able to get 5.3ms using buffer size=256, sample rate=48 kHz, and periods/buffer=3
Last edited by NLHybrid on Fri May 01, 2020 2:02 pm, edited 1 time in total.
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: Minimizing Latency (Am I missing something or am I screwed?)

Post by merlyn »

NLHybrid wrote:I listen to the sound through the internal soundcard (realtek alc898) ...
This seems at odds with your earlier statement that you are using a Native Instruments Komplete 2. If you're trying to use both that's where the problem is.
kulnova
Established Member
Posts: 19
Joined: Mon Apr 06, 2020 11:24 pm

Re: Minimizing Latency (Am I missing something or am I screwed?)

Post by kulnova »

Hi,

welcome to Linux audio production world. I'm very interested in replying to your topic because we share so many common things:

1. I'm also new to Linux audio production (not new to Linux). But I decided to use Archlinux for my main work horse for producing Audio a few months back.

2. I'm running an AMD machine too (which is low spec than yours, with Ryzen 5 2400G CPU). Using a lower end audio interface (Scarlett Solo gen 2), but I can get the latency to 10ms.

3. I'm producing MIDI, recording bass track, using microphone to record my bamboo flute.

According to your detail, I would give you some of my personal advice.

1. Don't follow that instruction link, because this is way out-date. Here's my problem that made me install Windows a year ago when I quit MacOS. Last year, I started with Manjaro KDE with this instruction link and it ran me crazy with no result. The instruction and the link are outdate IMO. A few months ago, I decided to give Manjaro a try without that link (I will share my way below). And after a few weeks using Manjaro, I decided to go with Archlinux, and now I would never go back. Manjaro just have many features that I don't need, especially the power saving that keep turning off my audio interface whenever I don't have any audio playing on my machine. That's annoying. I'm using Archlinux, so I just install whatever I need, lightweight and more effective.

2. The instruction was so wrong that I could never been successfully install Qjackctl. I have ended up using cadence. But I have just switched to Qjackctl a week ago with no look back. As candence is way too unstable :( Qjackctl is pretty easy to setup and work smoothly with PulseAudio (if you need)

3. In order to get a low latency, you don't really need to use the -rt kernel, but what you would need to do is adding your user to "audio" group and make audio configure in the /etc/security/limits.conf to realtime processing.

4. Instead of using the above instruction link, I installed all the package from Pacman and AUR. They have all you need.

For Manjaro setup, I suggest you go through this video instruction of Unfa, he will guide you through all the mandatory process to garantee to work https://www.youtube.com/watch?v=vgrqMv3Lzfk

I hope this could help you to get your Manjaro run smoothly.
Archlinux - Reaper for Music Production
Bass Player/Vietnamese Bamboo Flute Player for my music
User avatar
khz
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

Re: Minimizing Latency (Am I missing something or am I screwed?)

Post by khz »

How do I prepare Manjaro KDE for audio production? - https://www.youtube.com/watch?v=vgrqMv3Lzfk
. . . FZ - Does humor belongs in Music?
. . GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
  • I don't care about the freedom of speech because I have nothing to say.
User avatar
NLHybrid
Established Member
Posts: 5
Joined: Sun Apr 26, 2020 12:57 pm

Re: Minimizing Latency (Am I missing something or am I screwed?)

Post by NLHybrid »

merlyn wrote: Tue Apr 28, 2020 12:35 pm
NLHybrid wrote:I listen to the sound through the internal soundcard (realtek alc898) ...
This seems at odds with your earlier statement that you are using a Native Instruments Komplete 2. If you're trying to use both that's where the problem is.
I used the NI interface for my guitar in but I wanted to hear how bad the delay was so I patched it straight to playback(using pulseaudio bridge). There is a headphone in for monitoring (can blend between host and direct in), perhaps that could help as I wouldn't need pulseaudio to hear it right?
Last edited by NLHybrid on Tue Apr 28, 2020 5:40 pm, edited 1 time in total.
User avatar
Michael Willis
Established Member
Posts: 1451
Joined: Mon Oct 03, 2016 3:27 pm
Location: Rocky Mountains, North America
Has thanked: 69 times
Been thanked: 164 times
Contact:

Re: Minimizing Latency (Am I missing something or am I screwed?)

Post by Michael Willis »

NLHybrid wrote: Tue Apr 28, 2020 5:29 pm I used the NI interface for my guitar in but I wanted to hear how bad the delay was so I patched it straight to playback. There is a headphone in for monitoring (can blend between host and direct in), perhaps that could help as I wouldn't need pulseaudio to hear it right?
Yes, use the interface for both recording and playback. There are ways to use more than one audio device, but they are fraught with trouble, pain, and suffering.
User avatar
NLHybrid
Established Member
Posts: 5
Joined: Sun Apr 26, 2020 12:57 pm

Re: Minimizing Latency (Am I missing something or am I screwed?)

Post by NLHybrid »

kulnova wrote: Tue Apr 28, 2020 12:49 pm Hi,

welcome to Linux audio production world. I'm very interested in replying to your topic because we share so many common things:

1. I'm also new to Linux audio production (not new to Linux). But I decided to use Archlinux for my main work horse for producing Audio a few months back.

........................

For Manjaro setup, I suggest you go through this video instruction of Unfa, he will guide you through all the mandatory process to garantee to work https://www.youtube.com/watch?v=vgrqMv3Lzfk

I hope this could help you to get your Manjaro run smoothly.
Hi, thanks so much for you step-wise set of instructions. My initial post was a result of my brain being burnt out and just not wanting to take a rest. I've come back to it and gotten myself through a lot of steps that seem to be in that video luckily (before the installation of all the plugins). I'll update my original post accordingly with my updates and some interesting new findings that don't seem to be anywhere explicitly.
kulnova
Established Member
Posts: 19
Joined: Mon Apr 06, 2020 11:24 pm

Re: Minimizing Latency (Am I missing something or am I screwed?)

Post by kulnova »

NLHybrid wrote: Tue Apr 28, 2020 5:39 pm
kulnova wrote: Tue Apr 28, 2020 12:49 pm Hi,

welcome to Linux audio production world. I'm very interested in replying to your topic because we share so many common things:

1. I'm also new to Linux audio production (not new to Linux). But I decided to use Archlinux for my main work horse for producing Audio a few months back.

........................

For Manjaro setup, I suggest you go through this video instruction of Unfa, he will guide you through all the mandatory process to garantee to work https://www.youtube.com/watch?v=vgrqMv3Lzfk

I hope this could help you to get your Manjaro run smoothly.
Hi, thanks so much for you step-wise set of instructions. My initial post was a result of my brain being burnt out and just not wanting to take a rest. I've come back to it and gotten myself through a lot of steps that seem to be in that video luckily (before the installation of all the plugins). I'll update my original post accordingly with my updates and some interesting new findings that don't seem to be anywhere explicitly.
A screenshot of your Cadence setting page my help. I'm not sure about the IRQ you mentioned, but the chosen interface should be in the format "hw:USB". I made the same mistake to select "hw:Device" instead, and it took me days to figure out that I should choose "hw:USB" instead.
Archlinux - Reaper for Music Production
Bass Player/Vietnamese Bamboo Flute Player for my music
kulnova
Established Member
Posts: 19
Joined: Mon Apr 06, 2020 11:24 pm

Re: Minimizing Latency (Am I missing something or am I screwed?)

Post by kulnova »

One more thing that I have forgot to mentioned (that I have figured myself for my case to get it work - not from the YouTube video), that I have to install the following packages from pacman:

1. alsa-firmware
2. alsa-lib
3. alsa-utils
4. pulseaudio-alsa
5. pulseaudio-jack

One more package that I have also install (but I think it's optional - recommended on Arch wiki) is realtime-privileges and add my user to realtime group
Archlinux - Reaper for Music Production
Bass Player/Vietnamese Bamboo Flute Player for my music
User avatar
NLHybrid
Established Member
Posts: 5
Joined: Sun Apr 26, 2020 12:57 pm

Re: Minimizing Latency (Am I missing something or am I screwed?)

Post by NLHybrid »

I did a bunch of more things that didn't help. I actually found that the rtirq script won't work for the way my interface is connected. It is in an IRQ that is related to PCIe and doesn't fall within the bounds of what the general documentation out there tells us about how to adjust the RT Priorities for the devices. I would like to share some other commands that I found helped me identify the interface along with their PIDs and IRQ much easier than what I saw on a lot of sites.

rtstatus
lsmod -l
rtcards
aplay -l

Regardless, it seems that I went too deep without going back to check some simple things. After double-checking some of my RTPRIO settings in limits.conf. I just took a step back and tried setting both my input and output in cadence to the my interface. With settings:

Buffer Size: 256 Frames/period
Sample Rate: 48kHz
Periods/buffer: 3

I see 5.3ms, with 0 xruns at no load, so problem solved....I was hoping that I could monitor through my internal soundcard but I guess that's not going to be possible since it was causing the horrendous xruns.

My only last question is, will there be a way I can monitor myself properly(using some plugins like compression and noisegate) when using my mic into jack but listening to audio from my soundcard/pulseaudio apps?

Much appreciated to all the comments for my first post! :)
Post Reply