22 January 2009

Making Real-time audio, with Mandriva Linux and Rolands Edirol UA-25ex (usb powered sound card), using jackd

Making Real-time audio with
Mandriva Linux and Roland's
Edirol UA-25ex (usb powered sound card), using
jackd, qjackctl, Ardour, Hydrogen, Rosegarden and fluidsynth.

Topical Index

Current system Hardware
Find appropriate Kernel
rpm's info and choice
I used a perl script to check my system, ref. http://arnout.engelen.eu/files/dev/linuxmusicians/realTimeConfigQuickScan.pl
Patching the kernel
Manual (diy) Edirol Patch by blablack, ref. http://ubuntuforums.org/archive/index.php/t-908845.html
Manual (diy) RT Patch(Linux Journal video)ref. http://www.linuxjournal.com/video/hyper-low-latency-audio-real-time-kernel
Configure the kernel, (use Gentoo guide...)http://proaudio.tuxfamily.org/wiki/index.php?title=Howto_RT_Kernel
Compile and install the Kernel
Give apps real time access, install and configure set_rlimits
Run perl script check edit files to comply with script
Reconfigure and compile if required.
Test recording in Ardour with Hydrogen Drums controlled by jackd (not documented yet, but it works for me)


To achieve real time monitoring of multi track sound recording on a personal computer
with Open Source Software. We will probably have to compile twice or more,
until all the requirements are met, so
don't worry if you miss something the first time through.

Current System Hardware

My system, Mandriva 2009.0 official release kde4.1.3(mdv)
Asus M3n78-EH AM2 motherboard,
2x 1gig kingston 800mHz DDR2, AMD64x2 5600+,
Edirol UA-25EX (24/96) usb sound.
nVidia 9800gt 512Mb ddr3 (pci-e x16), Zalman ZM750-HP PSW
numerous usual storage devices.

Find appropriate Kernel, rpm's info and choice

First thing I had to do was get a kernel that supported the new usb audio card.


I started with the newest available, from Mandriva cooker, 2.6.28 rc...x86_64.(2009.1)

Once I turned off the on-board sound chip in bios, this kernel allowed the device to work
out of the box. (start-up music found it's way to the speakers, without configuring)

But I want Real-Time support!

The new kernel has the Edirol devices already installed. But I want Real-Time support.
I could not get a real-time patch for the new kernel, and to make one is out of my league.

Mandriva has RT type kernels available in .rpm packages from the contrib
and contrib/updates repositories. The real-time patched vanilla kernel...

The tmb kernel has Mandriva patches and third-party drivers I generally use so I'll start
there as a configuration basis, kernel-tmb-desktop-

Then I will patch the rt-kernel-source with the Edirol patch to get the usb-audio module
to recognise my new sound card.

rpm's info and choice...

The RT kernel is vanilla and has no Mandriva tweaks, so to keep the tweaks I configured the
RT source from the old tmb config file. The versions overlapped in the right order.

kernel-rt-source- - The source code for the Linux kernel
The kernel-rt-source package contains the source code files for the Linux kernel.
The source files are only needed if you want to build your own custom kernel that
is better tuned to your particular hardware.
NOTE: This kernel has no Mandriva patches and no third-party drivers,
only Ingo Molnar -rt (real-time) series patches applied to vanilla kernel.org kernels.

kernel-tmb-desktop- - Linux Kernel for desktop use with x86_64
The kernel package contains the Linux kernel (vmlinuz),
the core of your Mandriva Linux operating system.
The kernel handles the basic functions of the operating system:
memory allocation, process allocation, device input and output, etc.
This kernel is compiled for desktop use, single or multiple x86_64 processor(s)/core(s),
using voluntary preempt, CFS cpu scheduler and cfq i/o scheduler.
This kernel relies on in-kernel smp alternatives to switch between up & smp mode
depending on detected hardware.
To force the kernel to boot in single processor mode, use the "nosmp" boot parameter.
The tmb kernels is an experimental kernel based on the kernel.org kernels with added patches.
Some of them may/will never end up in the main kernels due to their experimental nature.
Some refer to this kernel as a 'hackkernel' ... Use these kernels at your own risk !!

you can do this (install) on a Mandriva system with smart or urpmi, if you have a
current rpm and urpmi database...(for smart too?) Smart is a package manager,
like synaptic, available from the
MDE repos. Ref. http://www.mde.djura.org/index.html (I like it a lot)

smart install kernel-tmb-desktop- kernel-rt-source-

urpmi kernel-tmb-desktop- kernel-rt-source-

Note: I did not install the rt-kernel rpm, just the tmb-kernel and rt-kernel-source rpms,
to save on downloads and to keep the “Mandriva tweaks and proprietary drivers”.

RT= "to bring hard real-time scheduling capabilities to the Linux Kernel,
with worst case latency and code execution in the tens of micro seconds."
(Linux Journal video)ref. http://www.linuxjournal.com/video/hyper-low-latency-audio-real-time-kernel

Note: I use the video also in manually patching the kernel with an rt patch and
setting rt access for the programs. I used that video and this perl script (next)
to set up my system for jackd.

I used a perl script to check my system,

By following this perl program, I found what I needed to change for optimum Audio Response

Check the system with “realTimeConfigQuickScan.pl...found here

perl script to report if you need to adjust ticks, or smp, etcetera.

you can run it from another shell terminal, (Konsole has tabs like firefox)
and it just reports to screen what needs to be done. Beautiful!

You can use the shift+PageUp or shift+uparrow to scroll back up the page.
Make a list, although they wont all be kernel config changes, It checks for several things,

"Checking for Ingo Molnar's Real-Time Preemption, Checking for tick less time support, Checking for 1000hz clock, Checking for High Resolution Timers,
Checking filesystem types, Checking tmpfs mounted on /tmp, Checking filesystem 'noatime' parameter, Checking the ability to prioritize processes with (re)nice, Checking whether you're in the 'audio' group, Checking for multiple 'audio' groups, Checking sysctl settings (inotify max_user_watches), Checking for resource-intensive background processes, like kpowersave."

We'll run this check again later to be sure we have everything in it's list.

“to be sure, to be sure!”

Patching the kernel...

Patch the kernel with the Edirol patch.
Patch the kernel with the RT patch.


Before I configured the kernel it needed to be patched and hacked a bit,

I edited the lines in the new Makefile to reflect the name I wanted to use for my kernel...

and added the Edirol patch to the RT kernel....

vi is a handy editor, We need admin rights to “save these files here”...

su (enter root password)

vi /usr/src/linux/Makefile

Quick vi tute
vi is operated in a shell, like Konsole or term

Quick keys...

I = insert “edit mode”
Esc = exit mode/s
:w = write
:q = quit
:wq! = force write quit (does not always over-ride the admin permissions)

/usr/src/linux/Makefile (Only showing the top 5 lines or so)...

EXTRAVERSION = -music.8-1.rt13.1mdv
NAME = GamesBox.GlennsPref.net

uname -a reveals the details of the running kernel (reflected from the installed kernel),
I don't want them all named “x.x-x-custom-x.x”,
I like task names more than reference numbers in my boot loader,
less geeky, more task oriented.

uname -a

glenn@GamesBox:~/bin$ uname -a (22-01 13:33)
Linux GamesBox.GlennsPref.net 2.6.26-music.8-1.rt13.1mdv #3 SMP PREEMPT RT Wed Jan 14 20:45:45 EST 2009 x86_64 AMD Athlon(tm) 64 X2 Dual CoreProcessor 5600+ GNU/Linux

Patch the kernel with the Edirol patch.

Copy the lines from the code box below to a file named

Change to the directory and run the patch...

cd /usr/src/linux/sound/usb
sudo patch < Edirol-patch.diff Note: When tested (25-01-2009, 12:09), the response was “patching file usbaudio.c Reversed (or previously applied) patch detected! Assume -R? [n]”

I [ctrl+c] to kill the process, Because I installed the patch before this demo.

I believe this process of "how and where to patch" the kernel is concise now.
The Edirol UA-25EX Patch code...
ref. http://ubuntuforums.org/archive/index.php/t-908845.html

Copy all text in the next frame...(except the html tags, "blockquote") ;-)


Add Alsa support for Roland Edirol UA-4FX in Advanced mode
(for MIDI support and sample rates of 48 kHz and 96 kHz)
usbaudio.c, usbquirks.h
Signed-off-by: david.c.hubbard@gmail.com
diff -u sound/usb/usbaudio.c.00 sound/usb/usbaudio.c
--- sound/usb/usbaudio.c.00 2007-11-28 02:13:10.000000000 -0700
+++ sound/usb/usbaudio.c 2007-11-28 02:44:47.000000000 -0700
@@ -2930,7 +2930,7 @@

- * Create a stream for an Edirol UA-700/UA-25 interface. The only way
+ * Create a stream for an Edirol UA-700/UA-25/UA-4FX interface. The only way
* to detect the sample rate is by looking at wMaxPacketSize.
static int create_ua700_ua25_quirk(struct snd_usb_audio *chip,
@@ -2950,8 +2950,11 @@
struct audioformat *fp;
int stream, err;

- /* both PCM and MIDI interfaces have 2 altsettings */
- if (iface->num_altsetting != 2)
+ /* both PCM and MIDI interfaces have 2 altsettings,
+ * except UA-4FX at 48 kHz, PCM interface has 3 altsettings */
+ if (iface->num_altsetting != 2 &&
+ (chip->usb_id != USB_ID(0x0582, 0x00a3) ||
+ iface->num_altsetting != 3))
return -ENXIO;
alts = &iface->altsetting[1];
altsd = get_iface_desc(alts);
diff -u sound/usb/usbquirks.h.00 sound/usb/usbquirks.h
--- sound/usb/usbquirks.h.00 2007-11-28 02:15:11.000000000 -0700
+++ sound/usb/usbquirks.h 2007-11-28 02:17:51.000000000 -0700
@@ -1311,6 +1311,37 @@
/* TODO: add Edirol MD-P1 support */
+{ /*
+ * This quirk is for the "Advanced" modes of the Edirol UA-4FX.
+ * If the switch is not in an advanced setting, the UA-4FX has
+ * ID 0x0582/0x00a4 and is standard compliant (no quirks), but
+ * offers only 16-bit PCM at 44.1 kHz and no MIDI.
+ */
+ USB_DEVICE_VENDOR_SPEC(0x0582, 0x00a3),
+ .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
+ .vendor_name = "EDIROL",
+ .product_name = "UA-4FX",
+ .data = (const struct snd_usb_audio_quirk[]) {
+ {
+ .ifnum = 0,
+ },
+ {
+ .ifnum = 1,
+ },
+ {
+ .ifnum = 2,
+ },
+ {
+ .ifnum = -1
+ }
+ }
+ }
/* Roland SH-201 */
USB_DEVICE(0x0582, 0x00ad),

Always leave a blank line at the end of config files, so the shell program (zsh, bash, etc)
knows it's a valid end of file (eof). Ensure when you compile your kernel to activate the
module snd_usb_audio [USB_AUDIO]. When you lsmod, it should be in the list.

If you have the RT kernel-source installed, your free to build the kernel, you may need to do
this again, it's ok, it's just time. I had to do the config twice or more before I completed the
exercise, but I think we'll just install each part once. You should still be in the /usr/src/linux

make xconfig
go to Device Driver->Sound->Alsa->USB devices and activate the module USB-Audio
(by blablack)

Check with the perl script to be sure...

reference pages...
Patch the kernel with the Edirol patch if required, by blablack,
The kernel patch Edirol FA-4x and UA-25ex From the Ubuntu forums...
links to this alsa wiki page...
Which links to the previous ua-25 page.

Next is the rt kernel patch...
Note: You only need to do this if you have not installed the rt kernel source from the rpm,
as mentioned above, if you did you can skip this Patching section and continue on to the
configuring the kernel section of this document.

Patch the kernel with the RT patch.

manual patch method,

from the video. (includes applications rt permissions and access with set_rlimits)...

download and patch any rt diffs.
I could not find a real-time patch for the new 2.6.28.x-kernel at...

You might find that you need to revise what kernel .ver you need to use, as I did,
Once I realised this I used the rpm method instead. Same versions, less work and the
“Mandriva tweaks and proprietary drivers”.

Download the patch (a .bz2 file in this case)to an appropriate place...
/usr/src/linux/patch- (or whatever version you require)

cd to the src dir (or where you saved the file to)...
cd /usr/src/linux

run bzip2 -d for the .bz2 file to unpack it in the src directory...
bzip2 -d patch-

Now patch the kernel by running...
patch -p1 < style="font-weight: bold;">Configuring the kernel

We'll need to configure further, We'll integrate the patch, type...
cd /usr/src/linux

running make oldconfig will only ask NEW questions not answered in the old (current) config
make oldconfig

say yes to the real-time preemption question, preempt_rcu and preempt_rcu_Boost
and any deps (none I noticed).

You can say no to the others or leave them as dynamic loading modules.
(depending on the age of this document, Jan-2009)

Some questions may be debugging apps, but generally you really won't want a lot of
low level apps running taking notes and writing reports while you're trying to record and sequence sounds.
So you can probably leave the debugging and kernel hacking out or unchanged if you like.
I turned off “Kernel_Debugging” as a whole.

This Gentoo guide is concise, (ignoring distro centric commands and) look for the selections to
change in the kernel.

Once that is finished, you can run the build sequence...

Another way to do this is with with a GUI, make xconfig or make menuconfig
you can get right down to the nitty gritty of selections, with a search function
with your mouse and you can browse around. :-)

cd /usr/src/linux

Note: I would run “make oldconfig” first, answering the questions then save. Then...
make xconfig


make menuconfig

check to see if rt has been enabled,

Search for “real-time preemption” and “preempt_rcu” and any deps (preempt_rcu_Boost),

you can probably leave the debugging and kernel hacking out or unchanged if you like.

Make sure the snd_usb_audio module is loaded in the config.


I also look for spcaxxx module for my webcam, and option module for usb_storage
“usb hdspa modem”.
I check to see if the agpgart modules are dynamic not static for my amd/nVidia combo.
I also check for write access to ntfs file systems.

Save your config then exit the xconfig app.
make sure you save the config file with the save button/icon and exit xconfig program.

That should save the config file to the default place... /usr/src/linux/somewhere.
You'll see on the shell, “saved config file to....”(Be sure you know where it is).

Config complete.

Compiling the kernel

Note: The rolling of the kernel (compiling) takes longest, up to 2 hours on most machines
It has been recommended to me not to run any other memory or filesystem intensive
applications on the system while the compiling is being carried out.

Otherwise type...
make all && make modules_install && make install

Note: make all, this does... make dep && make clean bzImage modules

Reboot selecting the new kernel, should be automatic with grub2 Mandriva system...
Shutdown -r now

Note: If you want this to run during the night, let say, and to shut down automatically
when the process is complete, type this instead...
make all && make modules_install && make install && shutdown -h now

Then go to work, or bed and check it when you return.

If you get errors, or stoppages, please ask before you reboot to the new kernel,
you can always fall back to the old kernel if you have booting problems.

Other than the package manager references, this is a good guide for any distro...IMO
Gentoo guide...http://proaudio.tuxfamily.org/wiki/index.php?title=Howto_RT_Kernel

Compile complete.

I got this from a Linux-Journal video tutorial(.flv) called

ref. http://www.linuxjournal.com/video/hy...al-time-kernel

To configure the system applications use the alsa examples...

Get set_rlimits...
(set_rlimits is only one of a few programms that enables this type of functionallity)


“This file sets the maximum priorities which set_rlimits can set for
a given program when executed by a given user or group.
The program specified must include an absolute path.”

Uncompress it with...
tar xf *


make clean && make

and when your ready to install it, run...
make install

Now get ready with you favourite editor, with root privileges

to edit some system files...

vi is a good one. ;-)

usually /etc/set_rlimits.conf

We want access to the @audio group and any of it's members (or a username),
Note: you should be a member of that group.

The next is the absolute address to the binary, then the nice level, real-time priority,
and memlock for the binary to run in.


@audio /usr/bin/jackd nice=-1 rtprio=80 memlock=100000
@audio /usr/bin/qjackctl nice=-1 rtprio=79 memlock=100000
@audio /usr/bin/ardour nice=-1 rtprio=78 memlock=400000
#@audio / =-1 rtprio= memlock=
@audio /usr/bin/hydrogen nice=-1 rtprio=76 memlock=100000
@audio /usr/bin/rosegarden nice=-1 rtprio=75 memlock=100000
@audio /usr/bin/vkeydb nice=-1 rtprio=74 memlock=100000
@audio /usr/bin/qsynth nice=-1 rtprio=73 memlock=100000

/etc/security/limits.conf (if ardour complains about memory limits)

@audio - rtprio 99
@audio - memlock 500000
@audio - nice -10

/etc/sysctl.conf for …

#checking inotify max_user_watches... too small. For Real-time Audio...
#** /proc/sys/fs/inotify/max_user_watches is smaller than 524288
#** increase it by adding 'fs.inotify.max_user_watches = 524288' to /etc/sysctl.conf and rebooting
# For more information, see http://wiki.linuxmusicians.com/doku.php?id=system_configuration#sysctl.conf
fs.inotify.max_user_watches = 524288

and any others mentioned in the perl script, like tmp fs listing.

Set up the server path in qjackctl to read, set_rlimits jackd

I also preceded the music programs commands with this as well, by editing the icon properties.

Type in set_rlimits jackd to start the server from a prompt.

Check with the video and perl script to check everything is as it should be.
There are references to some of the pages I have trolled through to assemble this document,
and you can check those for configuring the kernel, Alsa, and checking the hardware.

Repeated links from above...
Kernel http://proaudio.tuxfamily.org/wiki/index.php?title=Howto_RT_Kernel

Alsa http://ubuntuforums.org/archive/index.php/t-908845.html
Contributed to by the Ubuntu community and Blablack in particular

Note: The UA-4FX page has more command line utility examples for debugging.

Which links to the previous ua-25 page.

Before starting with jackd

jack with 64 frames per second and a buffer of 4 periods, at 44.1kHz 16bit
latency is about 5.6msec but jack has drop-outs in the audio chain,
X runs... :-(

After set_rlimits jackd

jack with 64 frames per second and a buffer of 2 periods, at 44.1kHz 16bit
gets about 2.6msec, with no x runs

(x runs = audio-processing lock-ups causing drop-outs, caused by resource scheduling).

I try to get in a habit of using one resolution most of the time,
after all, CD quality is still 44.1kHz/16bit.


Check for basic system sounds, configure kernel for virtualBox and nVidia Graphics
see here for updates...http://www.linuxquestions.org/blog/glennspref-112299/

After going through all of this, you won't want Mandriva Automatically Upgrading
your kernel for you.

To change this behaviour for urpmi (and drakrpm?) go to /etc/urpmi/skip.list
Use the config help in that file, /^kernel*/ you need to be root to save it.
Smart has a version lock, where you can lock packages by version from the smart GUI, nice.

So we have not covered installing the programs, but
I figure there's other documents about that already.

I used Audacity to check the audio recording and playback systems
during the kernel configs. (without jackd running)

Thank you to the contributors of Alsa, Ubuntu, Linux Journal Magazine, www.atomicmpc.com.au
and www.LinuxQuestions.org and you too (for reading).

I have tried to reference others work where I could, and give credit where it is due.

I apologise for any omissions, and accept any useful criticism,
amendments will be made as they become available and or relevant.

Thank you
Regards Glenn (GlennsPref) 27/01/2009

Format and minor changes, 08/02/2009


  1. I believe the Linux Journal video you are looking for is right here: http://www.linuxjournal.com/video/hyper-low-latency-audio-real-time-kernel

    you'll find a handy search window in the top right corner at LinuxJournal.com will lead you to many wonderful goodies. ;)

    -Katherine, The Webmistress

  2. thank you Katherine. You're quite right.