According Wikipedia, "Latency is a time delay between the moment something is initiated, and the moment one of its effects begins. The word derives from the fact that during the period of latency the effects of an action are latent, meaning "potential" or "not yet observed"."
Not all latency is perceptible. When somebody plays guitar, there is latency: there is a time between the moment fingers touch the strings and the moment sound is listened. However, this latency is imperceptible: listener don't distinguish both events (touching and listening).
Perceptible latency is a problem when latency shouldn't be perceptible :) as, e.g., realtime communications (telephone) or audio live recordings. According Dave Phillips,
"In the audio domain, studies have indicated that the ear is sensitive to timing differences at the millisecond level, perhaps even down to a single millisecond. However, latencies under 7 msec are not typically perceptible and are considered acceptable for desktop and semiprofessional applications. Systems achieving average latencies of less than 5 msec should be considered ideal platforms for professional latency-critical applications."
So, in audio domains, latency of less than 5 msec i.e., (1 second divided by 1000) times 5) is ideal; of between 5 and 7 msec is acceptable and above, inadequated.
If audio processing latency is above 7 msec and is necessary realtime responses (i.e., input, comput and output data must happen while one play or sing)) then will have a problem: latency will be perceptible. And the problem increase from discomfort to unacceptable levels, according latency increase.
Official linux kernel offers unacceptable latencies for audio domains.
(...) FIXME explain linux scheduler and preemption
deb http://pkg-freebob.alioth.debian.org/debian unstable main
And run:
# apt-get update
If strange error messages appear, take a look here. For install kernel-source and realtime preemption patch:
# apt-get install linux-source-KERNEL_VERSION linux-patch-rtwhere KERNEL_VERSION looks like 2.6.21.
Untar linux source:
# cd /usr/src # tar -xjf linux-source-KERNEL_VERSION.tar.bz2 # ln -s /usr/src/linux-source-KERNEL_VERSION linux
Test patch application
# cd linux # /usr/src/kernel-patches/all/apply/rtpreem
If something looks like...
START applying rtpreem patch (Realtime Preemption) Testing whether "Realtime Preemption" patch for KERNEL_VERSION applies (dry run): "Realtime Preemption" patch for KERNEL_VERSION succeeded Removing empty files: Done. END applying rtpreem patch... returns, so patch application is ok. Don't forget unpatch
# /usr/src/kernel-patches/all/unpatch/rtpreem
Config your kernel and clean tree:
# make menuconfig # make-kpkg clean
Apply patch
# /usr/src/kernel-patches/all/apply/rtpreem
Compile and make package
# make-kpkg --added-patches rtpreem kernel_image
Answer kernel config questions. If doubt, choice default options (only enter). After, compilation will start. When prompt returns, install package and reboot for test
# dpkg -i ../linux-image-KERNEL_VERSION_10.00_i386.deb # reboot
Try to run some application with realtime privileges (as root). By example:
# jackd -R -P 70 -d freebob
With libpam-modules normal user can run with realtime privileges. If you want install it, run, as root:
# apt-get install libpam-modules
Edit /etc/security/limits.conf. Add something looks like:
@audio - nice -10 @audio - rtprio 99 @audio - memlock 250000
Remember, these settings take effect only after (re)login. All users of audio group (cf. /etc/security/limits.conf) will can run programs with realtime privileges up to 70, e.g.
$ jackd -R -P 70 -d freebob
rtirq script enable setting realtime priorities . If you want install it, run, as root:
