Filed Under (Geekstuff, Linux, My Music) by Sean on March-3-2008

This is a follow up to the previous post located here.

Well I finally decided to get down and dirty once again and dive into the innards of real time kernel tuning. As I reported last time, I was getting some latency which was evident through the sound card as a very nasty buzzing sound. Here I’ll report some basic findings which hopefully will help anyone attempting to set up a real time system set up for use as a DAW.

My system is running Ubuntu Gutsy Gibbon. You may recall where I had some serious trouble installing the Ubuntu Studio real time Ubuntu kernel; the initrd image was severely anemic to the point where I couldn’t even boot up. Instead, I decided to download the latest kernel source and roll my own so I knew everything would be just the way I wanted.

Before I go into the step by step process of how that was done, allow me to report some updated findings that may clear up some confusion. One issue is deciding what method to use to grant realtime scheduling to users (so you don’t have to run programs as root, which is a very bad idea). The old way of doing things was to use the realtime-lsm kernel patch and module. The problem I was running into with this method along with the latest 2.6.24 kernels is the fact that you can no longer configure your kernel with CONFIG_SECURITY_CAPABILITIES as a module! The kernel maintainers have decided that it introduces some serious security vulnerabilities, so the only options now are built into the kernel or not at all. This is a serious problem when using realtime-lsm since presumably the capability module does not support stacking and needs to be unloaded when the realtime-lsm module is loaded. This is not completely true as pointed out by the Debian Kernel Team, but the realtime-lsm module patches I was using have not been modified to correct this. In any case, realtime-lsm has been deprecated in favor of the newer PAM rlimits method of granting realtime scheduling priority to userspace programs. It is important to note that realtime-lsm will still give you superior performance over the rlimits method for really heavy multimedia work, but in 99% of cases the rlimits method should suit most users just fine. The rlimits method works by configuring priority scheduling limits in /etc/security/limits.conf.

Let’s get to the meat of how I configured my system. I’m going to list all the steps in order with a very brief explanation of each.

First we get the latest kernel source tarball. In my case this was 2.6.24.3.

wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.xx.tar.bz2

Then we get the latest realtime kernel patch. Make sure the patch version matches your kernel version above. Get the latest rt version if there is more than one for your kernel. In my case this was patch-2.6.24.3-rt3.bz2.

wget http://kernel.org/pub/linux/kernel/projects/rt/patch-2.6.xx-rt.bz2

Copy the files to your kernel source tree, un-tarball them and patch the kernel. Be sure to use the proper version numbers below in place of these as applicable from your download.

cd /usr/src/

tar zjfv ~/linux-2.6.24.3.tar.bz2 linux-2.6.24.3 .

ln -s linux-2.6.24.3 linux

cd linux

bzcat ~/patch-2.6.24.3-rt3.bz2 | patch -p1

Get your current working config if you have one.

zcat /proc/config.gz > .config

or

cp /usr/src/linux-`uname -r`/.config ./.config

From the existing .config, if you have one, update the settings from it. If there are any new features from the last config file, you may be asked some configuration questions.

make oldconfig

Get your favorite editor out and modify the config file to match the following settings. If they don’t exist just add them to the end of the config file. Another option is to make menuconfig (or xconfig, gconfig, config, etc.) and set the values that way.

vi .config

HIGH_RES_TIMERS=y

PREEMPT_RT=y

HZ_1000=y

RTC=y

SND_RTCTIMER=y

SND_SEQ_RTCTIMER_DEFAULT=y

Now we can recompile and install our kernel. Below is the Debian/Ubuntu way of doing it. You can use the old school make && make modules && make modules_install technique as well. The Debian way does it all for you and packages the kernel image and headers as .deb packages in /usr/src and even installs the new kernel into GRUB!

make-kpkg --initrd --append-to-version=-rt_custom kernel_image kernel_headers

dpkg -i ../*deb

Now we grant realtime scheduling to the user group audio. Be sure your user account is part of this group. Here we set a max priority of 99 (RT), nice value of -10 (not very nice :) ) and memlock value of 512MB.
sudo cat "@audio - rtprio 99" >> /etc/security/limits.conf
sudo cat "@audio - nice -10" >> /etc/security/limits.conf
sudo cat "@audio - memlock 512000" >> /etc/security/limits.conf

Verify everything looks good in GRUB and reboot. Verify you’re running the new kernel. Look for PREEMPT RT in the version.

uname -ar

Linux ubuntu 2.6.24.3-rt3-rt_custom #1 SMP PREEMPT RT Sun Mar 2 22:06:11 CST 2008 i686 GNU/Linux

Great! Now you can run qtjackctl and select the appropriate realtime setting. You can launch your other studio applications with these settings as well and modify them in real time using the chrt command. You can check on the status of a process with ps -eo rtprio,comm.

ps -eo rtprio,comm | grep jack

chrt -p 99 <process id>

I will follow up with some more details and howtos regarding working with your DAW. Feel free to comment below if you have any questions or email me using the email icon at the top of the page. Enjoy!



Filed Under (Geekstuff, My Music) by Sean on February-17-2008

So now that I’ve decided I’m going to get serious about releasing the music I’ve composed for the better part of the last 25 years (and still write), I’ve been going through the process of learning as much as I can about Digital Audio Workstations (DAW). I’ve certainly played around with ProTools and other DAW software over the years but I really wanted to move everything to 100% open source running under Linux (see my previous article about moving exclusively to Ubuntu on all my systems). It appears the time has come for that to become a reality. I’ll be writing here about my experience in getting my DAW set up so others will gain from it. Here is the very rough list of the components of my DAW:

I still need to purchase either a good full-size electric piano or steal my mother’s Steinway Grand I had the privilege playing growing up. :) Another idea is to get a good, 88-key, weighted midi controller and use sampled sounds. I have written and arranged lots of multi-timbred works but much of my continuing composition these days is solo piano.

I will keep you posted on my continuing efforts. Also stay tuned for some initial recordings coming very soon!

(UPDATE) See http://www.seanstoner.com/blog/2008/02/19/linux-studio-chapter-ii/ for the follow up to this post.