JACK Audio Connection Kit

From ArchWiki
Jump to navigation Jump to search

If you know anything about JACK, please expand this article.


JACK2 - rewritten explicitly towards multiprocessor hardware

JACK2 is currently available in the [community] and can be installed from there using

pacman -S jack2


pacman -S jack2-dbus

Jack2 without D-Bus executes similarly to Jack1. With D-Bus, control is done using the jack_control utility. Run `jack_control` to see what it does. The important commands are listed below:

jack_control start  -  starts the jack server
jack_control stop  - stops the jack server
jack_control ds alsa  -  selects alsa as the driver (backend)
jack_control eps realtime True  -  set engine parameters, such as realtime
jack_control dps period 256  -  set the driver parameter period to 256

You may also need to play with the driver parameters nperiods and rate.


Alternatively, there is the normal version from the extra repository, install it with:

pacman -S jack

Basic Configuration


No matter which JACK edition you're using, you'll want a GUI configurator. Probably the de facto standard right now, is qjackctl:

pacman -S qjackctl



Configuring JACK can be a bit of a challenge. There will be more here soon. For now, try this general overview:


Most tutorials are advising a realtime kernel, which is quite helpful for live synthesis and FX; but for purposes of recording and editing it is not necessary anymore, as long as you set up for non-realtime latencies -- 10-40+ ms, and on older hardware 100-500+ ms.


The D-Bus edition of JACK2 can make startup much easier. Formerly, we had to have qjackctl start it for us, or use a daemonizer, or some other method. But as long as jack2-dbus is installed and dbus is running (which is Arch standard now), we can create a shell script as follows, to be run at GUI login:

jack_control start
sudo schedtool -R -p 20 `pidof jackdbus`
jack_control eps realtime true
jack_control ds alsa
jack_control dps device hw:HD2
jack_control dps rate 48000
jack_control dps nperiods 2
jack_control dps period 64
sleep 10
/usr/bin/a2jmidid -e &
sleep 10
sudo schedtool -R -p 20 `pidof a2jmidid`
qjackctl &
sleep 10
sudo schedtool -R -p 20 `pidof qjackctl`
qmidiroute /home/jeb/All2MIDI1.qmr &
sleep 10
sudo schedtool -R -p 20 `pidof qmidiroute`
yoshimi -S &
sleep 10
sudo schedtool -R -p 20 `pidof yoshimi`

The above will start a complete JACK live-synthesis setup, integrating several tools. Details will follow.

Jack for a multi-user system

So, you have a descent multiuser system as it was designed more than 20 years ago, and now some developers decided that sound is only for a mono-user system... No I can not believe it !

Warning: Before following the below instructions, please note that there is a security risk to any service running as root, and, more importantly, the developers for jack do not test it for running as root. In other words, it could eat your babies, data, or both

Fortunately some time ago someone convinced the developers to allow jack to run as a system wide daemon. Here is the procedure to follow:

Create a /etc/profile.d/jack.sh file containing:


Replace /etc/rc.d/jack-audio-connection-kit with the following content


. /etc/rc.conf
. /etc/rc.d/functions

# source application-specific settings
[ -f /etc/conf.d/jack-audio-connection-kit ] && . /etc/conf.d/jack-audio-connection-kit

PID=`pidof -o %PPID /usr/bin/jackd`

[ -n "$JACKUSER" ] && HOME="/home/$JACKUSER"
[ -z "$JACK_PARAMS" ] && JACK_PARAMS=$(sed 's:/usr/bin/jackd ::' $HOME/.jackdrc)

case "$1" in
    stat_busy "Starting JACK"
    if [ -z "$PID" ]; then
      if [ -n "$JACKUSER" ]; then
        su - $JACKUSER -c 'export JACK_PROMISCUOUS_SERVER="" && . /etc/conf.d/jack-audio-connection-kit && umask 0000 && /usr/bin/jackd $JACK_PARAMS &> /dev/null &'
	umask 0000
        /usr/bin/jackd $JACK_PARAMS &> /dev/null &

    if [ ! -z "$PID" -o $? -gt 0 ]; then
      add_daemon jack
    stat_busy "Stopping JACK"
    [ ! -z "$PID" ]  && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      rm_daemon jack
    $0 stop
    sleep 1
    $0 start
    echo "usage: $0 {sta|stop|restart}"
exit 0

Where my /etc/conf.d/jack-audio-connection-kit is

# Configuration for starting JACK at boot

# Uncomment this to run as user (recommended)

# Uncomment this to not source ~/.jackdrc
JACK_PARAMS="-R -P89 -dalsa -dhw:1 -r48000 -p512 -n3"

Playing nice with ALSA

To allow Alsa programs to play while jack is running you must install the jack plugin for alsa:

pacman -S alsa-plugins

And enable it by editing (or creating) /etc/asound.conf (system wide settings) to have these lines:

# convert alsa API over jack API
# use it with
# % aplay foo.wav

# use this as default
pcm.!default {
    type plug
    slave { pcm "jack" }

ctl.mixer0 {
    type hw
    card 1

# pcm type jack
pcm.jack {
    type jack
    playback_ports {
        0 system:playback_1
        1 system:playback_2
    capture_ports {
        0 system:capture_1
        1 system:capture_2

You needn't restart your computer or anything. Just edit the alsa config files, start up jack, and there you go...

Remember to start it as a user. If you start it with "jackd -d alsa" as user X, it won't work for user Y.


Example: watching a live stream without gconf

gst-launch-0.10 playbin2 uri=http://streamer.stackingdwarves.net/bewerungeroom.ogv audio-sink="jackaudiosink"

Setting gstreamer to use jack using gconftool-2

gconftool-2 --type string --set /system/gstreamer/0.10/audio/default/audiosink "jackaudiosink buffer-time=2000000"
gconftool-2 --type string --set /system/gstreamer/0.10/audio/default/musicaudiosink "jackaudiosink buffer-time=2000000"
gconftool-2 --type string --set /system/gstreamer/0.10/audio/default/chataudiosink "jackaudiosink buffer-time=2000000"

Further information: http://jackaudio.org/gstreamer_via_jack


If you need to keep pulseaudio installed (in the event it's required by other packages, like gnome-settings-daemon), you may want to prevent it from spawning automatically with X and taking over from JACK.

Edit /etc/pulse/client.conf, uncomment "autospawn" and set it to "no":

;autospawn = yes
autospawn = no

If you want both to play along, see: PulseAudio#PulseAudio_through_JACK_the_new_way


JACK can handle one soundcard very well, and an arbitrary number of MIDI devices (connected e.g. via USB). If you start JACK and want to use a MIDI keyboard or a synthesizer or some other pure MIDI device, you have to start JACK with a proper soundcard (one that actually outputs or inputs PCM sound). As soon you have done that, you can connect the MIDI device. E.g. with QjackCtl, you click on the connect button and you'll find your device listed under JACK-MIDI or ALSA-MIDI, depending on the driver.

For JACK-MIDI, you may want to set the MIDI Driver to seq or raw in QjackCtl Setup > Settings. This should make your MIDI device appear under the MIDI tab. You can also change the name of the client (from a generic "midi_capture_1" to something more descriptive), if you enable Setup > Display > Enable client/port aliases and then Enable client/port aliases editing (rename).

For ALSA-MIDI, make sure to turn on Enable ALSA Sequencer support in QjackCtl Setup > Misc. This will add the ALSA tab in QjackCtl Connect window where your MIDI controller will show up.

For bridging ALSA-MIDI to JACK-MIDI, you may consider using a2jmididAUR. The following command will export all available ALSA MIDI ports to JACK MIDI ports:

$ a2jmidid -e

They will be visible in QjackCtl under the MIDI tab labelled "a2j" client. You can automate starting of a2jmididAUR by adding to QjackCtl Setup > Options > Execute script after Startup: /usr/bin/a2jmidid -e &

Note: When connecting MIDI keyboard controllers in QjackCtl, make sure to Expand All first and connect the desired Output Ports (below the Readable Clients) to the Input Ports (below the Writable Clients). As a shortcut, if you select a writable client instead of individual ports as your destination, it should connect all its currently displayed output ports underneath.
  • Q: What's the difference between JACK-MIDI and ALSA-MIDI?
  • A: The former has improved timing and sample accurate MIDI event alignment. It extends or may even replace the latter but at this point they both co-exist.

To install some M-Audio MIDI keyboards, you will need the firmware package midisport-firmwareAUR in the AUR. Also, the snd_usb_audio module has to be available. For more information about specific USB MIDI devices, see http://alsa.opensrc.org/USBMidiDevices.


"Cannot lock down memory area (Cannot allocate memory)" message on startup

See: Realtime_for_Users#Add_user_to_audio_group

Problems with specific applications

VLC - no audio after starting JACK

Run VLC and change the following menu options:

  • Tools > Preferences
  • Show settings: All
  • Audio > Output modules > Audio output module: JACK audio output
  • Audio > Output modules > JACK: Automatically connect to writable clients (enable)

Related Articles