You are on page 1of 5

LINUXUSER JACK audio server

Exploring the JACK sound server system

KNOWING JACK

www.photocase.com
The JACK audio server offers a professional sound alternative for the

Linux desktop. BY DAVE PHILLIPS

M
ost Linux users know that a cording, the demands on an audio server and dropouts (known as xruns), and
server provides services, are relatively light. Managing several such systems are expected to support
whether on one machine or on audio streams at this level requires no the synchronous operation of multiple
a network. The purpose of a server is to sample-accurate synchronization, nor is clients in a low-latency environment.
eliminate the need to directly access there a need for a highly flexible client JACK comes with features such as:
these services at the application level. routing system. Most users simply want • support for any ALSA-compatible
For example, an X server manages access to be able to play recorded audio with- sound device
to and control of the video services of out blocking other audio streams. Artsd • support for a variety of audio system
the computer’s graphics chipsets, reliev- and esd are sound servers designed to back-ends (ALSA, OSS/Linux, Port-
ing user-level application developers of meet these requirements for the KDE Audio, CoreAudio)
the burden of programming for those and GNOME desktops. The Network • free connectivity between clients –
services directly. Audio System (NAS) is an alternative without delays or dropouts
An audio server manages access to the network-friendly client/server audio de- • support for a master transport control
capabilities and services of the installed livery system intended to serve as an system
audio devices. These audio devices in- audio equivalent of the X server. Within JACK’s primary task is the management
clude soundcards, on-board audio chip- their limits, Artsd, esd, and NAS all of multiple audio data streams, coming
sets, and any other audio hardware function effectively. However, none of from and going into a variety of appli-
(such as telephony hardware, combined these servers provides sample-accurate cations with synchronized I/O. JACK
A/V cards, television, and radio boards). synchronized I/O of multiple audio data requires an audio system – it is not a
The graphic Linux desktop depends streams, nor were they designed for per- replacement for an audio system such
upon X for its graphics and video ser- formance within low-latency systems. If as ALSA or OSS/Linux. JACK does not
vices. Thus, your favorite KDE or your audio needs require these high-end supply soundcard drivers, nor does it
GNOME applications include routines capabilities, you have ventured into the access hardware directly; instead it de-
for accessing those services through the domain of professional audio systems, pends on a low-level audio layer to han-
X application's programming interface. and now you need to know JACK. dle that communication, which in Linux
Programmers can code for the hardware is either ALSA or OSS. JACK doesn’t care
via a generalized API instead of having Introducing JACK about the underlying hardware, it simply
to directly address the hardware. Alas, Developer Paul Davis has created one wants to manage the streams coming
the sonic Linux desktop lacks a single of the most remarkable pieces of open- into and out of your devices.
standardized solution for serving audio source audio software, the JACK Audio
resources system-wide. Instead, a variety Connection Kit, better known as just Building and Installing
of solutions have appeared, including JACK. JACK is specifically designed for JACK
the artsd, esd, NAS, and JACK systems. systems tuned for low-latency and high JACK is available as a basic package
For triggering system sounds, listening demand. Professional audio recording in the AGNULA/Demudi and Planet
to CD and DVD audio, and simple re- systems cannot afford audible delays CCRMA audio-optimized systems. A

76 ISSUE 67 JUNE 2006 W W W. L I N U X - M A G A Z I N E . C O M


JACK audio server LINUXUSER

source tarball of the latest Note that the -p option sets the software
public release is available buffer size. As Jack O’Quin points out,
from the JACK website. this is the buffer size seen by all JACK
The site also provides in- clients.
structions for building See the box titled “JACK Options” for
JACK from CVS sources Figure 1: Controlling JACK from QjackCtl. more on command line options for
for those who want to JACK.
keep up with the latest development. No In this example, JACK has been started
special build requirements are needed with realtime capability, acknowledging GUIs for JACK
for JACK itself beyond Erik de Castro the ALSA back-end and addressing the We have already seen JACK in action at
Lopo’s libsndfile audio file I/O library. first hardware device in the audio the command prompt. However, when
According to the JACK FAQ, you must system. The -d hw:0 switch is actually working in an X environment it’s nicer
have a recent Linux kernel (2.4 or unnecessary; the hardware selection to have a GUI for JACK’s setup and con-
higher) with the tmpfs file system turned always defaults to hw:0 anyway. Obvi- figuration, and thanks to developer Rui
on. Most modern distributions will have ously, you would use a different number Nuno Capela, we have the wonderful
this turned on by default, but you can for a different card or chipset in a system QJackCtl (Figure 1). This most helpful
check for it by running cat /proc/filesys- with multiple sound devices. utility provides an all-in-one graphic in-
tems. The FAQ also states that you must Here’s a slightly more complex exam- terface for configuring and controlling all
mount a shared memory filesystem on ple for my SBLive soundcard : of JACK’s operations. In addition to the
/dev/shm, advising that the following convenient setup dialog (Figure 2), QJC
line be added to /etc/fstab: jackstart -R -d alsa -d hw:1U supplies an audio connections panel for
-p 512 -r 48000 -z s JACK clients and a set of basic JACK
shmfs /dev/shm shm U transport controls (if you want to use
defaults 0 0 Once again, we see the realtime and QJC as the JACK transport master). QJC
ALSA options. The device selector is further supplies messaging and status
The FAQ further notes that you may numbered hw:1 because the SBLive is display panels, controls to start and stop
have to create the /dev/shm directory the second card in that particular ma- the server, and play/pause controls for
yourself. chine. I’ve added options for the buffer JACK’s transport control system.
After unpacking the sources, simply size (-p), for the JACK sample rate (-r), QJC also includes a MIDI connections
enter the new JACK directory, read the and for the audio dithering option (-z). panel for ALSA sequencer clients, letting
README for up-to-date instructions,
then invoke ./configure --help to see the Regarding Soundcards
available configuration options. JACK is The audio industry distinguishes be- audio chipset supplies little more than
built with the familiar autotools utilities, tween consumer and professional grade the basic services, while my desktop
so for most users the compile process is audio devices. Consumer-grade devices machine’s SBLive provides a much
as easy as running ./configure [your include PCI and USB audio interfaces, larger array.
options here]; make; make install. on-board chipsets for integrated desktop Professional-grade audio boards such as
Installing JACK from an RPM or other and laptop sound support, and more ad- the RME Hammerfall or the M-Audio
package also requires no special support. vanced hardware such as Creative’s SB Delta cards are designed to satisfy differ-
Follow the basic installation procedure Live! and Audigy cards. These devices ent needs, providing higher-quality
normally provide channels for a master audio connectivity such as AES/EBU and
for your system, and voila, you have a
volume control, PCM and CD audio out- balanced 1/4” plugs, a greater number of
fresh JACK system ready for use.
put, and inputs for microphone and line- audio I/O channels, higher sampling
level signals. The master volume, CD,
Starting JACK mic, and line channels are self-explana-
rates, and hardware synchronization
capabilities. These professional-quality
The JACK server is launched with either tory. The PCM channel is a general digi- cards may or may not include hardware
jackd or jackstart. The JACK manual tal audio playback channel providing MIDI connectivity, and they do not usu-
page (man jackd) tells us that jackd in- volume control for programs playing ally include consumer-grade amenities
vokes the JACK server daemon and that WAV, AIFF, OGG, MP3, and other sound- such as an on-board synthesizer or a
jackstart is used when using JACK’s file types. connector to your CD drive’s audio
built-in support for realtime capabilities. Depending on the audio chipset, these output.
All options are the same for either invo- basic services may be expanded to in- The distinction between the grades is
cation. For most users working on sys- clude channels for on-board synthesizer obscured by some more advanced de-
tems with a patched 2.4 kernel, jackstart output, digital audio connections, sur- vices intended for the consumer market,
will be the preferred method of starting round sound channels, and bass/treble and it is certainly possible to achieve
the server. Users working with 2.6 ker- tone controls. Software mixers such as truly high-quality results from some of
alsamixer poll the audio hardware for its the more modern soundcards. However,
nels should use jackd.
capabilities and configure the mixer to for truly professional requirements you’ll
Here’s a relatively simple beginning :
display the available channels and need professional-grade audio hard-
switches. Thus, my laptop’s CS4232 ware.
jackd -R -d alsa -d hw:0

W W W. L I N U X - M A G A Z I N E . C O M ISSUE 67 JUNE 2006 77


LINUXUSER JACK audio server

users manage audio and MIDI connectiv- QJC is my favorite standard tool for based patchbay, but it appears that proj-
ity from a single control interface. You controlling JACK, but there are at least ect development is on hold.
can save and load your total connections two other GUIs for managing JACK con-
graph as a Profile in QJC’s Patchbay nectivity. Dave Robillard’s Patchage is a Applications Using JACK
(Figure 3). The Patchbay’s operation patchbay for both JACK audio and ALSA JACK support has become an expected
isn’t quite automatic, but it is a real MIDI connectivity via its unique visual feature in new Linux audio software. As
time-saver if your connections are many interface (Figure 4). Matthias Nagorni’s a result, the list of implementations has
and complex. QJackConnect is a nice JACK-only QT- become too lengthy to print here, but its

JACK Options
When you first meet JACK, you may be internal processing is always carried users. QjackCtl lets you select up to
confused by some of its options. This out at 32 bits, and by default, it will at- 512 ports, but more are available with
brief summary will help you find your tempt to set the bit resolution at its sufficient memory.
way around. input and output stages to 32, 24, and • -d, --driver – Select hardware driver. In
First the parameter settings: 16, in that order, reporting success or fact, you’re selecting the audio system
• -R, --realtime – Starts JACK with real- failure with each attempt. Users with back-end with this option. Currently
time scheduler priority. Normally, you cards known to work optimally at 16 supported systems include ALSA,
will want this option enabled, but be bits might want to use this option just OSS/Linux, CoreAudio, PortAudio, and
aware that it works only if you have to avoid the error reports. a dummy system (useful for testing).
root status or are running a kernel that • -H, --hwmon – Enables hardware mon- Most Linux users will want to choose
grants such status to a normal user. itoring of ALSA’s capture ports, provid- either ALSA or OSS.
Kernels from AGNULA/Demudi and ing zero-latency monitoring of audio • -r, --rate – Sets JACK’s sample rate.
Planet CCRMA are prepared for such input. Requires hardware and device The default is 48000 Hz, but you may
status, but any kernel can be patched driver support. The jackd man page need to experiment to determine the
and modified for low-latency with says when this option is enabled, “re- best sample rate for your system.
root-user capabilities enabled. Jack quests to monitor capture ports will be Lower-powered systems may find it
O’Quin indicated to me that JACK satisfied by creating a direct signal necessary to bring down the sample
needs root privileges only for realtime path between audio interface input rate to improve performance, but gen-
scheduling and memory locking. I and output connectors, with no pro- erally you want a rate of at least 44100
asked members of the Linux Audio cessing by the host computer at all. Hz for high-quality sound. Note too
Users mail list whether there might be This offers the lowest possible latency that some soundcards (e.g., the SB-
good reasons to not use the realtime for the monitored signal.” Live) work well only at a single sample
option, and I learned that JACK is still • -M, --hwmeter Another ALSA-only rate.
useful on systems without realtime option. Enables hardware metering • -p, --period – Specifies the number of
capability, hence the option. Addition- if your soundcard supports it. Paul frames between JACK’s process()
ally, you might want to turn off real- Davis notes that this option is used function calls. The default value is
time capabilities in a testing or trou- only rarely and that it is likely to be 1024, but for low latency you should
bleshooting scenario. removed in future releases. set -p as low as possible without pro-
• -m, --no-mlock – Signals JACK to keep • -z, --dither – Dithering is a process that ducing xruns. Larger periods yield
memory unlocked. Paul Davis ex- minimizes unwanted side-effects of higher latency but also make xruns
plained that this option could be useful reducing an audio file’s bit-depth. less likely, so you may have to experi-
when running JACK in realtime on a Low-level noise is mixed into a signal ment to find the optimal setting for
system whose physical RAM is being to randomize digital audio quantiza- your hardware. Incidentally, man jackd
consumed by JACK and its clients. tion errors, turning audible and un- tells us that JACK’s input latency (mea-
• -u, --unlock – Unlocks memory claimed pleasant digital distortion into some- sured in seconds) is --period divided
by graphics toolkits (GTK, QT, FLTK, thing more closely resembling analog by --rate.
WINE). Again, this option is useful for noise. According to Paul Davis, dither- • -i, --inchannels; -o, --outchannels –
machines with low amounts of mem- ing is especially helpful when your These settings determine the number
ory (physical RAM), but it is especially soundcard’s output is less than 24-bit of audio I/O channels. The default is
useful for users running VST/VSTi resolution and you run JACK at the the maximum number supported by
plugins and other WINE-dependent hardware’s real sample rate. your hardware.
applications. In some cases, such ap- • -P, --realtime-priority – Sets the real- • -n, --nperiods – Specifies the number
plications may not run at all until this time scheduler priority. Normally, of periods in the hardware buffer. The
option is selected. you can leave this setting at its default default value is 2. The period size (-p)
• -s, --softmode – Ignores xruns value of 10. If your kernel includes times --nperiods times four will equal
reported by an ALSA driver, making realtime preemption, you might want the JACK buffer size in bytes.
JACK less likely to disconnect unre- to set this value to at least 70 to keep • -C, --capture; -P, --playback; -D, --du-
sponsive ports when run without real- JACK running ahead of interrupt plex – Set JACK to record-only, play-
time status. You might select this op- handlers. back-only, or full duplex status (simul-
tion to avoid too-copious error reports. • -p, --port-max – Sets the maximum taneous play and record). This setting
This option might also be valuable for number of JACK output ports. This op- can be very important: Some cards
live performance. tion is especially valuable for people will simply not perform well in duplex
• -S, --shorts – Forces JACK’s I/O to 16 using a lot of tracks in Ardour. The de- mode but work quite well in the sim-
bits. As Lee Revell pointed out, JACK’s fault of 128 should be enough for most plex modes.

78 ISSUE 67 JUNE 2006 W W W. L I N U X - M A G A Z I N E . C O M


LINUXUSER JACK audio server

domains of implementation include plugins that lets


hard-disk recording systems (Ardour, you build a virtual
ecasound, Wired), drum machines/ rack of audio pro-
rhythm programmers (Hydrogen), cessing modules
software sound synthesis environments with MIDI control
(Csound5, SuperCollider3), audio/MIDI of plugin parame-
sequencers (Rosegarden, MusE, seq24), ters. Steve Harris’s
soundfile editors (Snd, Audacity, mh- JAMin is the result
WaveEdit, ReZound), and standalone of a collective
softsynths (AMS, Om, ZynAddSubFX). effort by Linux
Other significant JACK-savvy projects audio profession-
include the LinuxSampler and Specimen als to create a pro- Figure 3: QJC’s Patchbay helps you manage connections.
sampler projects and the various quality stereo
schemes for supporting VST/VSTi audio mastering interface based on LADSPA MIDI sequencer, the QSynth soundfont-
plugins under Linux (these schemes also audio signal processing plugins. Time- based synthesizer, and the JACK-Rack,
require the WINE software). Linux me- machine is another treat from Steve Har- all operating on my PII 366 Omnibook
dia playback systems such as MPlayer, ris. It’s essentially a recorder that always and its humble Crystal Sound CS4232
XMMS, and AlsaPlayer also provide maintains a buffer of the last ten sec- chipset. Figure 5 demonstrates a more
JACK support. onds of recorded material. When fully ambitious set of routing and connections
Readers should note that these appli- armed, Timemachine writes the buffer with JACK managing I/O.
cations vary in the scope of their JACK to disk and continues recording in real- There’s little more to say about using
support. Some use only its audio con- time. Fons Adriaensen’s JAAA (JACK JACK in these scenarios. Once I’ve con-
nectivity, some use only partial imple- and ALSA Audio Analyser) is a profes- figured JACK, its performance is com-
mentations of its transport control, and a sional-grade signal generator and spec- pletely transparent. All I have to do is
few already take more complete advan- trum analyser designed for accurate make my connections and make my
tage of JACK’s features. Please consult audio measurement. And just to show music.
the documentation for any JACK-aware that there’s no absolute need for a fancy
application to determine the extent of its GUI, Florian Schmidt’s jack_convolve is Programming With JACK
support. a JACK-based command-line convolu- Programming with the JACK API is be-
The basic JACK package includes a tion engine, very handy for creating yond the scope of this article. Interested
number of useful command-line tools high-quality reverb effects and other readers can find excellent instructional
such as jack_connect/jack_disconnect interesting sounds. material in the JACK source code (see
(manages client connections), jack_ URLs for all these and other JACK ap- simple_client.c in the example_clients
metro (a configurable metronome), jack_ plications are listed on the Linux Sound directory) and on various Web sites.
lsp (lists JACK ports, their connections & MIDI Software site [9]. James Shuttleworth’s tutorial at http://
and properties), and jack_transport www.dis-dot-dat.net/index.cgi?item=/
(manages JACK transport control JACK In Action jacktuts/starting/ is a well-written intro-
status). Figures 5 and 6 show off JACK in two duction to adding JACK to a simple
JACK has also inspired a wave of cool typical uses here at Studio Dave. Figure audio application, Lewis Berman has
tools and utilities. Bob Ham’s JACK-Rack 6 illustrates the simpler use in an audio- contributed a PDF on writing a JACK
is a very useful container for LADSPA plus-MIDI network combining the seq24 audio recorder at http://userpages.umbc.

Figure 2: The QJackCtl setup dialog box. Figure 4: Patchage is a patchbay for JACK and ALSA.

80 ISSUE 67 JUNE 2006 W W W. L I N U X - M A G A Z I N E . C O M


LINUXUSER JACK audio server

edu/~berman3/, and of course, the


JACK API can be read and studied in the
well-commented jack.h header file.
If you build JACK yourself and you
have the doxygen software installed, you
can generate JACK’s developer docu-
mentation. This documentation is also
available on the JACK website, but it is
out of date as of September 15, 2005.

JACK’s Future
In 2004, JACK won a well-deserved
Bronze award in the Merit Awards
granted by the Open Source Initiative.
At that point, JACK’s development was
at version 0.9x. As I write this article,
JACK is now at version 0.100.0, heading
steadily towards its 1.0 release, and the
future is looking good for JACK.
Stephane Letz has successfully ported
JACK to OSX. Support for OSX has be-
come common in new Linux audio soft- Figure 6: JACK with an audio-plus-MIDI network.
ware. Incidentally, an implementation
for Java has already appeared. sion with the Linux kernel sources, so bility has already been tested and veri-
MIDI musicians are familiar with time its presence in any Linux distribution fied in high-demand real audio world
code implementations not currently sup- results from a decision made by the dis- applications, and its applicability can
ported by JACK, and a coordination of tro’s producer. Also, JACK is not so be seen in an expanding suite of in-
synchronization capabilities would be transparent to the user as the artsd and creasingly powerful JACK-based pro-
most welcome. Some work in that direc- esd servers, and more configuration is grams. JACK’s API has paved the way
tion has already begun, so it is likely that required for obtaining best performance. for a new wave of high-quality Linux
a blend of MIDI and JACK will evolve. Nevertheless, JACK is a very flexible sys- audio applications. Whether you need
JACK’s attractions may seem irresist- tem and may yet become the de facto rock-solid audio system performance for
able, but it may not be the best solution audio server for the Linux desktop. Ardour or you just want to have some
for common desktop audio services. Un- For the more professionally inclined fun routing the output from XMMS, you
like ALSA, JACK is not planned for inclu- JACK is a godsend. Its performance sta- need to know JACK. ■

INFO
[1] The JACK Home Page:
http://jackit.sourceforge.net
[2] ALSA Soundcard Matrix:
http://www.alsa-project.org/alsa-doc/
[3] Patchage: http://www.scs.carleton.ca/
~drobilla/patchage/
[4] QJackConnect:
http://www.suse.de/~mana/jack.html
[5] QJackCtl:
http://qjackctl.sourceforge.net/
[6] Interview with Paul Davis at Builder.
com: http://builder.com.com/
5100-6375-5136755.html?tag=tt
[7] The Low-latency Mini-HOWTO:
http://www.djcj.org/LAU/guide/Low_
latency-Mini-HOWTO.php3
[8] Florian Schmidt’s notes on building a
low-latency 2.6 kernel: http://tapas.
affenbande.org/?page_id=3
[9] The JACK page at linux-sound.org:
http://linux-sound.org/jack.html
Figure 5: A more ambitious JACK configuration.

82 ISSUE 67 JUNE 2006 W W W. L I N U X - M A G A Z I N E . C O M

You might also like