Linux Tips On Jack And Realtime Audio

If you are running into troubles with JACK xruns or have glitchy audio you may try following things:
(Written assuming Ubuntu, commands and paths may vary on other distributions)

Check what is sharing IRQ with your soundcard

cat /proc/interrupts  

Should display you the list of IRQ’s on your system and devices using them. For example WiFi or other network drivers can cause lots of interrupts and thus taking time away from audio driver which should be priortized. Some other devices hardly cause any interrupts so they won’t cause much problems when they share IRQ with your sound card. Still, best option would be to make sure your audio device is alone on the IRQ.

To fix:

Some BIOS setting allow you to organize IRQ’s, but newer, specially laptop ones won’t. Some device cards and motherboards also used to have jumpers on them for configuring IRQ’s. Nowadays even this is rarely the case, but it may be worth to check.

Other option is to disable all integrated devices from your BIOS which you don’t use. Sometimes this will reorganize your IRQ tables and with some luck you may get more stable audio perfomance.

If you don’t need the annoying device, you may unload it’s module with “modprobe -r drivername” and/or blacklist it in “/etc/modprobe.d/blacklist”.

Prioritize your audio IRQ

First check which IRQ your sound card is on with the command in previous chapter and then (assuming it’s on IRQ 11) issue a command:

sudo chrt -f -p 60 `pidof IRQ-11`  

Where the 60 is the priority of the process from 0 to 100.

Word of warning: Prioritizing the thread too much may make your system unresponsive or entirely freeze everything except audio and program playing the audio. So be careful not to give too much priority to the thread.

Also, if something interrupt hungry is running on the same IRQ (like wifi card). This may lead to opposite results making the audio actually skip more.

Remove rogue drivers

Some buggy drivers get pretty crazy with some hardware configurations. Example of those drivers is b43 driver for Broadcom 43xx series WiFi cards. On some cards, it may cause very short, temporary system freezes which have high impact on audio.

Fortunately you can replace this driver for now with ndiswrapper driver which is much more friendly to the kernel for now. Don’t forget to blacklist the old driver.

Some other drivers have also alternatives available, but not all of them. Sometimes you have no other option than unloading the driver while working with audio and filing an angry bugreport.

CPU scaling

On laptops CPU speed scaling is usually on setting “ondemand” which means it will change the CPU speed accordingly to the requirements of CPU power at the moment. When running Renoise you are likely to need lots of CPU, so it will most likely switch itself on performance when playing tracks and back to slower speed when being idle.

This is not a good behavior as the frequency switching may cause timing issues and will lead to xruns. To fix it you may use following command:

sudo sh -c 'echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'  

And later, after messing with your audio, to make the fans calm down again:

sudo sh -c 'echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'  

Broken APIC implementation

Some HP laptops (and apparently some others) have broken APIC implementation in their bios. This causes the system driver instability which will lead to xruns. In some cases passing “noapic”, “nolapic” to kernel arguments may save the issues. But be careful, as disabling APIC will also disable multiprocessor support.

I will add more tips later, if I remember any.

You are a great resource.

Also… make sure you turn on the “RT” option in the jack settings, as it seems to always be off with a fresh install.

I thought RT is only useful if you also use an RT kernel.
It’s by the way one of the instructions that seems left out:how to exchange an ordinary kernel for a realtime kernel if you have an ordinary kernel.
As well as how to completely remove or shutdown CPU hungry window managers like Compbiz or Beryl.

Sorry… ive been away camping for a few days. Anyhow…
I’ve compiled a kernel before, but not an RT kernel. Following a guide, it went quite smoothly.

However…In my package manager,
linux-image-2.6.22-14-rt is the name of my current kernel… (so you’d want linux-image-..--rt whatever version number it may be in your distro0)
Im assuming It will drop in nicely with the package manager.
If your running Multiple drives/partitions and have grub in an unusual place, you may have to edit your grub menu to boot the correct kernel. (i had that problem once before as the package manager only updates grub in its regular place on the first boot device).

Also you may need linux-restricted-modules-rt if your using (example) nvidias closed source graphics driver.
Theres also a problem with nvidia closed source graphics and the rt kernel of a certain number, which causes a black screen of doom. Maybe its fixed now… dunno.

I use ubuntu studio, so ive not had to install the rt kernel myself.

But yeah, rt option is only useful on the realtime kernel.
With out the realtime kernel (only speaking from my experience) jack suffers from lots of xruns.