Installation

In order for JACK to work properly, your user needs to be added to the audio group for access to higher ulimits defined in /etc/security/limits.d/99-audio.conf, which is needed for realtime audio processing.

Note: You need to manually add your user to the audio group even if you're using logind, since logind just handles access to direct hardware.

There are two JACK implementations, see this comparison for the difference between the two. In short, Jack 1 and Jack 2 are equivalent implementations of the same protocol. Programs compiled against Jack 1 will work with Jack 2 without recompile (and vice versa).

JACK2

JACK2 is a C++ implementation with SMP support. Install it with the jack2 package. If you are on a 64-bit installation and need to run 32-bit applications that require JACK, also install the lib32-jack2 package from the multilib repository.

JACK2 D-Bus

JACK2 with D-Bus can be installed via jack2-dbus. It is the same as the jack2 package but does not provide the legacy "jackd" server.

It is controlled by the jack_control utility. The jack_control utility requires you to also install the python2-dbus package as well.

JACK

JACK uses a C API and supports more than one soundcard on Linux (plus MIDI). Install it with the jack package. If you are on a 64-bit installation and need to run 32-bit applications that require JACK, also install the lib32-jack package from the multilib repository.

GUI

cadence is the modern GUI control application. It can be installed with the cadenceAUR package.

qjackctl is more widely used, and still functions, but is now outdated and is not recommended.

Basic Configuration

Overview

The right configuration for your hardware and application needs depends on several factors. Your sound card and CPU will heavily affect how low of latency you can achieve when using JACK.

The mainline Linux kernel now supports realtime scheduling, so using a patched kernel is no longer necessary. However, linux-rtAUR in the AUR is a patched kernel that has some extra patches that can help to get lower latencies.

A shell-based example setup

The D-Bus edition of JACK2 can make startup much easier. Formerly, QjackCtl was used to start it, or a daemonizer was used, or some other method. But using jack2-dbus, JACK2 can be easily started and configured via a shell script.

The above will start a working JACK instance which other programs can then utilize. Details of each line follow. When discovering your own best configuration, it is helpful to do trial and error using QjackCtl's GUI with a non-D-Bus JACK2 version.

Details of the shell-based example setup

jack_control start

Starts JACK if it is not already started.

jack_control ds alsa

Sets JACK to use the ALSA driver set.

jack_control dps device hw:HD2

Sets JACK to use ALSA-compatible sound card named HD2. One can find the names with cat /proc/asound/cards. Most ALSA tutorials and default configurations use card numbers, but this can get confusing when external MIDI devices are in use; names make it easier.

jack_control dps rate 48000

Sets JACK to use 48000 khz sampling. Happens to work very well with this card. Some cards only do 44100, many will go much higher. The higher you go, the lower your latency, but the better your card and your CPU have to be, and software has to support this as well.

jack_control dps nperiods 2

Sets JACK to use 2 periods. 2 is right for motherboard, PCI, PCI-X, etc.; 3 for USB.

jack_control dps period 64

Sets JACK to use 64 periods per frame. Lower is less latency, but the setting in this script gives 2.67 ms latency, which is nicely low without putting too much stress on the particular hardware this example was built for. If a USB sound system were in use it might be good to try 32. Anything less than 3-4 ms should be fine for realtime synthesis and/or FX, 5 ms is the smallest a human being can detect. QjackCtl will tell you how you are doing; at no-load, which means no clients attached, you will want a max of 3-5% CPU usage, and if you cannot get that without xruns (the red numbers which mean the system cannot keep up with the demands), you will have to improve your hardware.

sleep 10

Wait for the above to settle.

a2jmidid -e &

Start the ALSA-to-JACK MIDI bridge. Good for mixing in applications which take MIDI input through ALSA but not JACK.

sleep 10

Wait for the above to settle.

qjackctl &

Load QjackCtl. GUI configuration tells it to run in the system tray. It will pick up the JACK session started by D-Bus just fine, and very smoothly too. It maintains the patchbay, the connections between these applications and any other JACK-enabled apps to be started manually. The patchbay is set up using manual GUI, but connections pre-configured in the patchbay are automatically created by QjackCtl itself when apps are started.

A GUI-based example setup

This example setup utilizes a more GUI focused configuration and management of JACK

Install qjackctl, and tell your GUI window/desktop system to run it at startup.

Make sure QjackCtl is told to:

use the D-Bus interface,

run at startup,

save its configuration to the default location,

start the JACK audio server on application startup,

enable the system tray icon, and

start minimized to sytem tray.

Reboot.

After logging in, you will see QjackCtl in your system tray. Left-click on it.

Tweak settings in the QjackCtl GUI to lower latency. The Frame Size, Frame Buffer, and Bitrate settings all affect latency. Larger frame sizes lower latency, lower frame buffers lower latency, and higher bitrate settings lower latency, but all increase load on the sound card and your CPU. A Latency of about ~5ms is desirable for direct monitoring of instruments or microphones, as the latency begins to become perceptible at higher latencies.

Playing nice with ALSA

To allow Alsa programs to play while jack is running you must install the jack plugin for alsa with alsa-plugins.

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

PulseAudio

If you need to keep pulseaudio installed (in the event it is 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":

Firewire

In order to prevent ALSA from messing around with your firewire devices you have to blacklist all firewire related kernel modules. This also prevents PulseAudio from using firewire. Create the following file:

MIDI

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 (qjackctl), you click on the connect button and you will 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 a2jmidid (a2jmidid). 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 a2jmidid 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 is 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.

Troubleshooting

jack2-dbus and qjackctl errors

Still having the "Cannot allocate memory" and/or "Cannot connect to server socket err = No such file or directory" error(s) when pressing qjackctl's start button (assuming that you have package jack2-dbus installed) ?