JACK

TL;DR
You should install Jack2 if you intend to use audio or video creation applications on Linux.

If you have any experience with traditional professional audio hardware (synthesizers, effects, mixers) or even professional networking gear (routers, switches, vlans), then you are accustomed to the notion that signals must be routed from one place, through a filter of some sort, to a target, and then perhaps through another filter, and then a final destination.

Patchbay by Pinnacle_College on Flickr.

JACK is an application that, once started, runs in the background and enables the user to freely route audio from any application to any other application. It is a system-wide implementation of what other audio applications can only do internally, and is one of the true “killer” features of Linux audio.

Whether or not you use JACK on a daily basis or just once a year depends on what you do with your computer. Most everyday applications are not designed to use JACK at all (ie, it has not been programmed to use be “JACK-aware”, but being open source, there are hacks around that), while others use JACK an an option, and still others require JACK to even launch successfully.

If you think you will use JACK because you do pro audio, then you should read this section and the related topics about the JACK frontends, qJackCtl (an all-in-one JACK configurator and patchbay manager), or Patchage along with the session manager aj-snapshot. You should learn JACK, how to use it effectively and efficiently, and how to integrate it with your system.

If you do not intend to use JACK, you can skip this section, but install Jack2 from http://slackbuilds.org just in the unlikely event that it's a soft requirement for some other applications that you may use later. Jack is not terribly large and it won't get in the way unless you manually start it, so it's worth having.

JACK Versions

There are two concurrently supported versions of JACK: Jack version 1 (numbered as Jack 0.x) and Jack version 2 (numbered as 1.x, and marked as Jack2 on SlackBuilds.org). They are interchangeable and both basically do the same thing. If you install the wrong version, neither you nor applications that use it will ever notice. However Jack2 includes significant additional features that make it worth using over the original: true multi-processor support, hot-pluggable application interaction, and network support (useful for integrating your Linux system with a hardware mixer, for example).

For most users, Jack2 is the best option.

However, http://slackbuilds.org lists jack-audio-connection-kit as a dependency for many of packages that actually only require either version of JACK. For this reason, you must:

JACK is a tool that you start and stop in the unix shell, so it will not appear in your K Menu.

Starting JACK

TL;DR

  1. aplay -l | grep card
  2. jackd -R -d alsa -X seq -P hw:?? -C hw:??

To start JACK, open a terminal and type in a sensible JACK command, as a normal user (not as root).

If you are using an ALSA-to-JACK hack, you probably need to load snd-aloop unless you have set it to load at boot time.

For example:

$ jackd --realtime \
-d alsa \
--midi seq  \
--playback hw:0

Decoded, this means:

  • jackd: invokes JACK, specifically the JACK daemon jackd. It will happily run in the background once launched, but you must not close the terminal window you used to launch it.
  • –realtime: opts for realtime performance. As long as you have set JACK up correctly, realtime or near-realtime performance will be possible (although it is also dependent upon your physical hardware).
  • -d: driver, with the backend of alsa because that's what Linux uses for its most basic audio system.
  • –midi: driver for MIDI data streams, with the backend of seq (sequencer), because that's the most compatible option and inherits the ability to be controlled and routed by JACK (ALSA MIDI does not). The seq option drives, generally, most USB MIDI devices (such as keyboards and controllers). It may not work for more complex devices like hybrid hardware and software synth controllers.
  • –playback: the audio device to use for playback, set to hw:0.
  • Missing from this example is –capture, which would be set to a capture device such as hw:1, if required.

Most of this is either self-explanatory or else you can just take on faith for now and forever until something important doesn't work for you (if you buy a MIDI-capable interface and –midi seq no longer works, then you'll know to investigate alternate drivers.

The most confusing decision will be the playback and capture devices, especially intimidating due to the unfamiliar names like hw:0. But don't panic; these are just abbreviations for card numbers as seen in

$ aplay -l | grep card

or

$ cat /proc/asound/cards

You have only to determine which output and input device makes sense for you, as described in the Linux Audio section.

For example, given this setup:

$ aplay -l | grep card
card 0: SB [HDA ATI SB], device 0: ALC887-VD Analog [ALC887-VD Analog]
card 0: SB [HDA ATI SB], device 1: ALC887-VD Digital [ALC887-VD Digital]
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
card 3: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
card 3: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]

One might set card 0, expressed to jackd as hw:0 as the output device because it is pretty clearly, of the three choices, the analogue speakers.

If one was using a digital output, then one might set the output device to hw:0,1; that is, using card 0's digital output port: card 0, device 1.

If one wanted to use HDMI instead, then the output device would be hw:1,3 or hw:1,7, depending on which physical port one uses (that particular card has both an HDMI and a mini HDMI port, which I can confirm by looking at the back of my computer).

If one plugged in a USB microphone to the same computer and re-ran the aplay or cat commands, a new card is available:

$ aplay -l | grep card
card 0: SB [HDA ATI SB], device 0: ALC887-VD Analog [ALC887-VD Analog]
card 0: SB [HDA ATI SB], device 1: ALC887-VD Digital [ALC887-VD Digital]
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
card 2: DSP [Plantronics .Audio 626 DSP], device 0: USB Audio [USB Audio]
card 3: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
card 3: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]

$ cat /proc/asound/cards | grep '\['
0 [SB       ]: HDA-Intel - HDA ATI SB
1 [NVidia   ]: HDA-Intel - HDA NVidia
2 [DSP      ]: USB-Audio - Plantronics .Audio 626 DSP
3 [Loopback ]: Loopback - Loopback

Now the command to start JACK can be altered to suit:

$ jackd --realtime \
-d alsa \
--midi seq  \
--playback hw:0 \
--capture hw:2

Which makes the capture device (sound input) card 2 and the playback device (sound output); the USB microphone and the analogue speakers, respectively.

Adding missing devices to JACK

If a device isn't available in JACK, you can add it using the alsa_in command along with the device designation you get from the aplay -l | grep card output.

$ alsa_in -d hw:2 &

Now the device is available to JACK.

Routing JACK

Launching JACK with the basic infrastructure of where you want to hear sound, and, optionally, from what peripheral you want to be able to input sound, is all you need to get started with music-making on Linux. Once JACK is running, you can use any number of graphical frontends to route sound in and out of one application to another, and from one speaker to another, as needed.

The popular frontends for JACK are:

  • Patchage: a node and noodle view of audio inputs and outputs.
  • QJackCtl: a full command center with access to sound routing, JACK configuration, patchbays, and sessions.
  • Cadence: a diverse and multi-purposed control center from KXstudio

muse.jpg

This section covered, in great detail, the way JACK routes sound and how ALSA lists peripherals. That means that you are equipped to use JACK to route signals in and out of the computer but you have not actually tried routing sound in and out of the software running on the computer yet.

Each individual sound application covered in this handbook will address typical routing schemes, so if you're feeling a little lost or like you have an incomplete picture of what routing sound actually entails, don't worry. Any JACK-aware application in this handbook will be accompanied by advise on how to route the application (but really you'll be able to figure it out on your own).

Read the sections on QJackQtl and Patchage to learn about routing signals to and from the JACK-aware software you use.

Read the MIDI appendix for detailed information on routing MIDI signals in a meaningful way.

R S Q