In my DJ setup, I use the JACK sound server to link my mixing program to a bunch of fun effects. It is possible to get JACK to perform at extremely low latencies (~6ms and less) but it’s hard to get all the options just right. For the benefit of others who don’t want to go through the same trial and error I did, here is the command line I’m using to launch jack:
jackd -R -P 99 -p128 --timeout 4500 -d alsa -d AUDIO4DJ -p $size -n $periods -i 4 -o 4 -r 44100
Here’s what all that means:
- -R: Realtime mode
- -P 99: Realtime Priority value (maxed out)
- -p 128: max jack ports
- –timeout 4500: client timeout in ms. This is very important, because Mixxx might hang for longer than the default 500ms when it’s loading tracks. If that happens, JACK kicks out Mixxx and playback stops
- -d alsa: Use ALSA backend
(Note, after this argument, the rest of the arguments are ALSA-specific
- -d AUDIO4DJ: use the AUDIO4DJ alsa device (see my previous post)
- -p $size -n $periods: These two options are what determines the size of the sound buffer. The first number is the frame size, in bytes (I think). The second is the number of frames. Multiply the two together to get the total size. With a special realtime kernel, I can set this to 64 and 4 (total: 256, or about 6ms). With a standard kernel, it has to be 128 and 3 (total: 384, 9ms). The idea is you want to get the total multiplied number as small as possible without inducing the dreaded XRUN, which happens when your computer can’t feed audio to the sound card fast enough.
- -i 4 -o 4: 4 inputs, 4 outputs
- -r 44100: CD-rate audio
Yeah, I know, if I just bought a mac and Traktor or Serato I wouldn’t have to deal with this shit, but I’m cheap and can’t resist a challenge.