The Jack low-latency sound server has been ported to OS X from Linux. We discuss its background and implications.
The UNIX core of Apple's OS X means that, with appropriate modifications, it can make use of software originally created on other UNIX-family platforms. Ready availability of source code and licenses which allow derivative versions of programs make the process all the more likely, with most Linux and BSD (Berkeley Software Distribution) distributions featuring thousands of packages which are anything but exclusive, since a program found on one UNIX platform is generally available to any other. Apple quietly acknowledged this aspect of UNIX when they used parts of the Konqueror web browser, developed on Linux, as the basis of their Safari.
Perhaps the single most significant pro audio project on Linux is the Jack audio server (see the feature on Mirror Image Studios, SOS February 2004), which has now been ported to OS X, with good results, and thanks to some handy features in the Mach microkernel underlying Apple's UNIX, may even outperform the Linux original. A free download, Jack has been tested on OS 10.2.6 and later versions, including Panther. Unlike Propellerheads' Rewire interconnection protocol, it doesn't require specific application support, being capable of connecting any application that is Core Audio-compatible, and it can allow a third application to act as an effects insert with the use of a VST or Audio Units plug-in. At the same time, a growing number of Linux audio programs are adding native Jack support.
Jack Tools isn't the only software to bring the Rewire concept up to date. Cycling '74 have released Soundflower, which is similar in concept, if not in detail. It's also available as a free download, from the Cycling '74 website. Dan Nigrin (see main text) isn't dismissive of the rival effort: "Soundflower is a great piece of software, and in some ways it's a shame that the Jack OS X team and Matt Ingalls, who developed Soundflower for Cycling '74, didn't know about each other's work until after we each released our respective applications. Soundflower was originally introduced in beta form to the Max/MSP mailing list as MSP Patcher, literally on the day we announced Jack OS X — go figure!"
Nigrin argues that these two alternatives to Rewire both have their merits, and that there's no reason why OS X users shouldn't download and try both. "Soundflower 's advantage is that it's simple — just select the driver and go. Also, there are a few applications that Jack currently has trouble interacting with — specifically some of the Native Instruments ones — and Soundflower seems to do better with those. On the other hand, Jack OS X is more flexible than Soundflower; it's not limited to either two channels or 16. Applications that don't allow you to choose separate input and output drivers will have their options limited when using Soundflower. Jack 's extension into the AU and VST plug-in space allows for more complex audio patching configurations between (and within) applications. And the fact that Jack is open source, and — at least in the Linux world — has a large developer base, ensures that it will continue to develop and improve."
Letz adds: "Soundflower is a Core Audio kernel driver that uses a buss approach; this is a simple solution, but it's less flexible. Jack allows for centralised control of the running applications' connection state, giving the ability to save and restore setups. The architecture of Jack allows you to describe any kind of connection graph between audio clients, as long as there aren't loops."
I talked to Dan Nigrin, a member of the Jack Tools project, who also runs the Defective Records label in Baltimore, USA. "Although Rewire works beautifully on applications that have Rewire functionality built into them, either as client or host, it unfortunately does nothing for those that don't," comments Dan. "Where Rewire still has advantages is that it allows for MIDI and transport information to flow between connected applications. We hope to have this functionality in Jack Tools in upcoming versions; the Jack architecture definitely supports it."
Working on the project at GRAME, a national musical institute in France, Stéphane Letz explained why the Jack Tools team felt the need to go beyond Rewire. "Our first goal in porting Jack to OS X was to get a free, flexible and low-latency audio server that had already proved its utility on Linux, thus facilitating the port of Linux audio programs to the Mac. The Jack Audio Router, a driver that allows any Core Audio application to access the Jack server, was developed as a second step, giving all Core Audio applications the ability to take advantage of Jack 's capabilities."
Jack isn't a simple clone of Propellerheads' existing system. "The Rewire and Jack architectures are quite different," says Stéphane Letz. "Rewire allows an audio master application to run and synchronise slave applications — all audio code runs in the context of the master application, and the GUIs of the client applications run in the client context. By contrast, Jack is based on a client/server model, with the Jack server at the centre of the system. It interacts with the soundcard driver and communicates with all registered clients. Each node in the Jack 'client graph' has its own process functions, which have to be called in a specific order. The whole graph is executed synchronously by the hardware driver, typically waking the server at regular intervals determined by its buffer size. The Jack server then distributes this audio interrupt to all running clients."
Architectural merits aren't the only advantage of Jack, as Letz explains: "Developing a Rewire-enabled application requires its developer to adapt the program's source code. With the Jack Audio Router driver for Core Audio, there is no need. The Jack approach allows for any kind of connection topology, and is therefore very flexible. Extensions can be developed very easily in the future." In addition, the proprietary nature of the Rewire protocol creates licensing problems for third-party developers porting free software from other UNIX-family platforms. Jack Tools development team member Johnny Petrantoni adds: "Consider that Rewire is written using the old binary Macintosh style CFM [Code Fragment Manager format, used in the classic Mac OS]. There is a lot of wrapping required to make it work in a Mach-O [Mach object file format] application, and of course this creates processing overhead."
The crucial factor in acceptance of either Jack Tools or Cycling 74's Soundflower (see 'Soundflower' box, earlier) is likely to be real-world reliability. After all, neat routing features aren't much use if the audio infrastructure starts to throw up problems halfway through a critical mixing session. The Jack Tools team found that OS X machines can suffer from clock drift in certain configurations, as Letz relates: "The clock drift problem is a tricky one as soon as several audio drivers are used at the same time in an application, and there is no generic solution provided by Apple yet."
Fortunately, Jack Tools doesn't suffer from this particular problem. "By design the Jack server uses the real soundcard driver it is connected to, and all Jack clients share the same timing source. We may add multi-driver support in a future version so that we can use several soundcards at the same time, but then we'll need to solve the clock drift problem at the Jack server level. One real driver would be the master and all other drivers would have to be synchronised to that."
A few workarounds exist already which enable multiple soundcards to be used with Jack, such as in the scenario where a laptop musician or DJ needs a cue mix on headphones but only has a single stereo output on their external audio interface. For example, the pre-listening outputs in Ableton's Live can be routed via a virtual four-channel Jack device to an application which uses the internal soundcard on the laptop, while the main outputs are routed to the external interface.
Putting audio routing under control of the CPU rather than a fistful of cables means that a split-second glitch could cause audio output to fail completely, should the sound server stop. However, Nigrin is reasonably confident that Jack is ready for serious work: "Purely from anecdotal personal use, it's incredibly stable if your CPU can manage the various applications you're connecting. There is a theoretical limit over which Jack would begin to drop clients, but I don't think we've encountered this ourselves, or heard about it on our Jack OS X forum."
Letz explains that it's the audio applications that need to keep up with Jack, rather than the other way around. "The fundamental requirement for audio applications is that they complete their work during the audio cycle. If three apps are running in Jack at 64 frames per buffer, the sum of their audio callback duration must not exceed the duration of one 64-frame buffer; that's about 1.45 milliseconds. The Jack server contains profiling code to measure each application's audio callback duration at every cycle. The profiling code may decide to drop an application that cannot meet its deadline, and remove it from the Jack client graph."
Direct comparisons of performance between the three systems — Rewire, Jack and Soundflower — are difficult to make, due to the differences in architecture. "We have not yet made extensive formal performance comparisons," says Letz. "The original Jack Tools version had some room for improvement, and we are currently working on a new simplified design for the Jack server that will be even more optimised, and will take advantage of multi-processor machines." This forthcoming version of Jack Tools, currently in beta, will also include the NetJack application, enabling audio to be streamed between different studio machines on a network, using UDP packets (see Glossary).
As complex as it might seem, Nigrin claims that using a VST or Audio Units plug-in to send and return Jack audio streams directly into an application is no less stable than connecting to Jack with main inputs or outputs. "It's really no different than using it via a Core Audio driver. When using a Jack VST or AU plug-in, you create an audio window into an application via its plug-in interfaces. So, for instance, you could allow an application to send audio to the Jack server via a stereo-track effect-send channel using the plug-in; from there, you could have the Jack server send the audio on to another application for processing, and then return that audio back into the first application, via another VST or AU plug-in instance on another channel."
It could be that the limitation on routing between audio applications in future will be our ability to comprehend and keep track of the connections, rather than any technological constraint. "It's a bit of a challenge to enable users to visualise all of these connections," says Nigrin. "This kind of flexibility is really quite new for everyone. One of our goals for the future is to be able to come up with a graphical connections manager, instead of the tabular one we have now, as we think that this will allow people to better understand the signal flows that are possible."
- Distribution: The traditional way that a free UNIX is packaged. Operating system, drivers, utilities and applications all in one bundle.
- BSD: The Berkeley Software Distribution, a free UNIX originally produced at the University of California and mostly used on servers. A lot of BSD technology was incorporated by Apple into OS X.
- Linux: Usually taken to mean GNU/Linux, an operating system designed from scratch as a free implementation of the UNIX concept. Runs on just about any hardware, including Apple and PC.
- UDP: User Datagram Protocol, a method for sending data over an Internet Protocol (IP) network.
- TCP: Transmission Control Protocol, used by web and email servers instead of UDP.