A BRIEF INTRODUCTION TO ALSA, JACK, AND LADSPA

ALSA, JACK, and LADSPA are three of AGNULA's most important components. Each provides a unique service, yet all work together seamlessly to create an environment rich in possibilities for programmers and end-users. ALSA provides high-quality drivers for your sound hardware, JACK supplies professional-grade connectivity for out-of-process programs, and LADSPA provides a remarkable toolkit filled with plugins for signal and effects processing, digital synthesis building blocks, and an array of other instruments and processors. Their importance to AGNULA is critical, so let's give them some further attention.

ALSA

ALSA is an acronym for the Advanced Linux Sound Architecture. The name is most usually encountered when discussing soundcard drivers, but ALSA is much more than a mere collection of modules. The main page at the project's Web site informs us that ALSA's primary characteristics include support for audio and MIDI hardware ranging from consumer-grade to professional-quality, fully modularized drivers for that hardware, a multiprocessor-friendly and thread-safe design, an API (applications programming interface) and a user-space library (libasound) for programmers who want to access the properties and capabilities of the sound system, and full OSS/Free compatibility (OSS/Free is the previous kernel sound system API) for running Linux audio applications that do not explicitly support ALSA. And of course ALSA is completely free and open-source software licensed under the GPL.

The AGNULA distribution has already built the ALSA driver modules and installed the library for you, so all you need to do now is configure your system for its particular audio and MIDI hardware. The Options menu will let you configure and re-configure your system at any time; alternately, you can run the alsaconf utility manually from any xterm or console. For the normal user ALSA and its functions are completely transparent, and there should be little or no need for dealing with ALSA once it has been configured for your machine. After basic configuration the only time any low-level ALSA component becomes visible to the user will be as an interface or driver option in certain JACK-aware applications (see below for information about JACK).

The ALSA package also includes a variety of important tools such as the arecord/aplay programs, the alsamixer, and the aconnect MIDI connection utility. We will encounter them frequently throughout this documentation, so I will leave their detailed descriptions for later presentation.

For Programmers Only: Dr. Matthias Nagorni's ALSA 0.9.0 HOWTO is the recommended guide to learning the basics of programming for ALSA so I will not repeat his sage advice here. Interested coders can find and read the good doctor's guide by selecting it from the AGNULA Documentation menu. I also recommend studying Paul Davis's excellent tutorial on using the ALSA API (see again the Documentation menu). ALSA gives programmers a powerful API for audio coding, and its library functions are not difficult to access; however, it is possible to further reduce audio programming effort at this level by including an interface to the JACK audio server.

KNOWING JACK

JACK is another acronym, a recursive one this time, standing for the Jack Audio Connection Kit. JACK lives in the domain of audio servers, a class of software that includes the Enlightened Sound Daemon (esd, the sound server for the GNOME desktop) and artsd (a similar server for the KDE desktop). Both esd and artsd provide a handler for multiple audio streams, but they are primarily designed for incidental sound support such as desktop event sounds and lightweight game sound. In contrast, JACK provides a multiplexing service that manages numerous simultaneous audio streams with stable low-latency throughput. JACK-aware clients can stream data from one to another without discontinuities in the multiple streams. The server has been designed for high-priority performance, and for best results a kernel patched for low-latency (such as the AGNULA kernel) is recommended. JACK's design also includes a master transport that enables master-slave device configurations between clients for simultaneous control of start/stop/pause and other transport operations.

The AGNULA distribution is already prepared for JACK. The JACK daemon (jackd) is installed, as are all other parts of the JACK package. Various applications included in AGNULA are JACK-aware, and special instructions are given when JACK clients are presented in this documentation. Some applications will supply a selection of possible audio interfaces listing JACK among them: JACK's capabilities include allowing applications to run as normal apps in their own process-space or as plugin clients within the JACK server structure.

For Programmers Only: Linux audio application programmers are well-advised to support JACK. Its programming interface relieves the programmer of the need to write for the relatively low-level ALSA or OSS library functions. Only a simple JACK callback procedure needs to be written into an application in order for it to act as a client on the JACK bus, essentially shifting the management of any required audio services to the JACK server (while promoting modularity and code re-use). Applications programmers should consider JACK at the start of their program design, but it really isn't too difficult to add JACK support to existing applications. JACK-ifying an existing application will require a rewrite of the program's audio I/O code, but happily the JACK package includes a number of small test applications for diagnostics and study.

Jörn Nettingsmeier has drawn this detailed map to graphically illustrate the workings of JACK :

Figure 1: The JACK connection map (Click to enlarge)

The server's internal structure provides stable management of separate data streams, incorporating a variety of driver types (though only ALSA and OSS are currently supported) and utilizing the ALSA library to its full capability.

ALSA + JACK + ?

An impressive number of JACK-aware applications already exist, and more are coming all the time. A partial list includes the following programs :

All of these applications are included in the AGNULA distribution, and the system developers are busy adding more all the time. AGNULA developer Günter Geiger has programmed a useful library (libjackasyn) that is designed to ease the JACK-ification of non-JACK-aware applications, and that library has already enlarged the above list.

JACK also behaves nicely with the LADSPA plugins supported by many of the applications listed above. Ah, but did I hear you say "What's LADSPA" ? Well, read on...

LADSPA

Yet another acronym (you may have guessed by now that UNIX programmers love their acronyms), this time standing for the Linux Audio Developers Simple Plugin Architecture, LADSPA is to Linux audio applications what the VST plugin standard is to the popular music and sound software for Windows and the Mac, with the bonus of being free and completely open-source.

The LADSPA SDK (system development kit) is divided into the plugin API, a small collection of basic plugins for study and use, and a set of utilities for listing and describing the plugins available on the system. Once again the AGNULA distribution has already installed the contents of the SDK for you, and a large number of additional plugins have been installed from Richard Furse's CMT (Computer Musician's Toolkit) and Steve Harris's impressive collection. Note that many other applications utilize the LADSPA plugins, including the Snd and Audacity soundfile editors and the terminatorX looping DJ-style "scratcher". Using these plugins is typically transparent to the normal user: you select a plugin from a menu and apply it to an edit region or as a realtime effect during a performance.

Many LADSPA plugins are very impressive. I especially recommend trying the tape delay, the retro flanger, the graphic and parametric EQs, the Freeverb reverb effect, the high-quality pitch shifter, the plate reverb... Oh, there are too many to mention here, so just try them all !

As with ALSA and JACK, Linux audio application programmers are urged to include support for LADSPA in their programs. Fortunately this is not a difficult task: the API is well-commented and easy to understand (the designers laid special emphasis on the "Simple" part of the architecture), and if you feel a need for more information you can refer to the Looking Into LADSPA article listed in the AGNULA Documentaion menu.

THE GREATER SUM

So: ALSA, JACK, and LADSPA, an outstanding Linux audio software trio. Indeed, it is possible to use only these three components to build a powerful Linux audio environment. GUIs are available for most of the package utilities, such as the ALSA mixer (alsamixergui) and aconnect (alsa-patch-bay), and Linux audio developer Bob Ham has written an excellent "JACK rack" that can act as a virtual rack-mount system for LADSPA plugins. We have here only scratched the surface of what is possible with this software, and we will further explore some of those possiblities in later chapters. Let's proceed with those explorations now...