Using JACK with FFADO

This is a very brief overview for those aspects of JACK specific to FireWire audio devices. For generic information about JACK look at the JACK homepage or work the Google magic.

The JACK daemon (jackd) has two sets of options: general and backend-specific ones.

You can display the general options with

$ jackd -h
jackd 0.112.0
Copyright 2001-2005 Paul Davis and others.
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details

usage: jackd [ --realtime OR -R [ --realtime-priority OR -P priority ] ]
             [ --name OR -n server-name ]
             [ --no-mlock OR -m ]
             [ --unlock OR -u ]
             [ --timeout OR -t client-timeout-in-msecs ]
             [ --port-max OR -p maximum-number-of-ports]
             [ --debug-timer OR -D ]
             [ --verbose OR -v ]
             [ --clocksource OR -c [ c(ycle) | h(pet) | s(ystem) ]
             [ --replace-registry OR -r ]
             [ --silent OR -s ]
             [ --version OR -V ]
             [ --nozombies OR -Z ]
         -d backend [ ... backend args ... ]
             The backend can be `alsa', `coreaudio', `dummy',
                                `freebob', `oss', `sun', or `portaudio'.

       jackd -d backend --help
             to display options for each backend

The FFADO-specific options are

$ jackd -d firewire -h
no message buffer overruns
Parameters for driver 'firewire' (all parameters are optional):
        -d, --device    The FireWire device to use. (default: hw:0)
        -p, --period    Frames per period (default: 1024)
        -n, --nperiods  Number of periods of playback latency (default: 3)
        -r, --rate      Sample rate (default: 48000)
        -i, --capture   Provide capture ports. (default: 1)
        -o, --playback  Provide playback ports. (default: 1)
        -I, --input-latency     Extra input latency (frames) (default: 0)
        -O, --output-latency    Extra output latency (frames) (default: 0)
        -x, --slave     Act as a BounceDevice slave (default: 0)
        -X, --slave     Operate in snoop mode (default: 0)
        -v, --verbose   Verbose level for the firewire backend (default: 0)

Basic setup without real-time scheduling

The simplest way to use FFADO with JACK is without real-time privileges on a standard kernel. You won't achieve very low latency that way, but it should be good enough for some basic audio work, unless your interface is very picky wrt to timing or has a massive amount of I/O channels.

$ jackd -d firewire -n 3 -p 2048

Real-time scheduling

Many FireWire interfaces will require real-time (RT) scheduling. Since RT processes can effectively hog the entire CPU, only root can obtain RT scheduling by default. For reasons of security and system stability, it is a very bad idea to run audio stuff as root. Instead, you will have to grant real-time privileges to ordinary users via the rlimits mechanism. As root, edit the file /etc/security/limits.conf and append the following lines (unless they exist already):

# grant real-time privileges to members of group "audio"
@audio  -       rtprio  99
@audio  -       memlock unlimited
@audio  -       nice    -10

The whitespace can be spaces or tab stops. What you just did is this:

  • all members of the audio group can obtain realtime priority 99
  • all members of the audio group can lock all physical memory that will never get swapped out
  • all members of the audio group can de-nice their applications to be scheduled for longer than normal

Of course, you will need to become a member of the audio group. Either use your distribution's user manager, or do the following as root:

$ groupmod -A ''your_user_name'' audio

You will need to log out and back in for this new group membership to become effective.

Now you can start JACK with real-time scheduling. Note that realtime (-R) is the default since jackd-0.118, hence the flag is redundant.

$ jackd -R -d firewire -n 3 -p 2048

This should improve robustness and stability a lot, and you can now experiment with lower latencies.

Low-latency setup

The following setup will achieve latencies below 5 ms. It will require an RT-patched kernel for stable performance.

$ jackd -R -d firewire -n 3 -p 64

Alternate firewire ports (old firewire stack, ieee1394)

If you have a device on the second firewire port and you're not using the new Juju firewire stack, you need to provide the -d option to the firewire backend (don't be confused about the two -d options: the first is handled by JACK, the second by libffado).

$ jackd -d firewire -d hw:1

The first (and default) port is hw:0, then hw:1, hw:2 and so on.