AC3Jack is a tool for creating an AC-3 (Dolby Digital) multichannel
stream from its JACK input ports. Using this tool, an AC-3 stream (up
to 5.1 channels) is created in real time and either written to a file or
streamed to a SPDIF output.

If the SPDIF port on your audio interface for connection to a
multichannel surround receiver, you can achieve full 5.1
surround mixing and monitoring of your JACK applications with a
single digital cable, and no need for hardware supporting discrete
outputs and inputs.

AC-3 is a compressed audio stream, so quality will suffer
somewhat, but it is the price you pay for easy surround sound.
The AC-3 encoder used here comes from the Aften project and although the sound quality seems good,
I haven't seen any direct quality comparisons with commercial encoders.

Aften --
version > 0.0.8 The release on their site is not up to date with their development. AC3Jack uses their more
recent API, a snapshot you can use is aften-20080622-r762.tar.gz.
You will need CMake in order to build Aften.
Currently, the libaften_static.a is not installed with make install, you need to copy it to
/usr/local/lib/ before building ac3jack.

libsigc++-1.2 - note that this is an older version you may have to
install separately, but try it first you might have it.

GUI Usage

The main ac3jack executable now has a GUI for easy control of the various options at runtime.
There is also a command line version called ac3jack_cli. Both are capable of being controlled remotely
via OSC using the messages specified in the OSC API.

If portname arguments are added, they are initially connected in channel order, if possible.

Notes

The allowable bitrates for AC-3 encoding are nominally variable from
32-640 kbits/s, but there are common conventions and recommendations
for bitrate based on channel count. Only certain bitrates are likely
to be accepted by the codec as well.

2 ch -- 192
5.1 (6 channel) -- 448

However, if doing live streaming to hardware consider using the highest quality bitrate of 640.

The sample rates allowable are 32, 44.1, and 48kHz. Note that for use
as part of DVD soundtracks multiplexed with MPEG2 files, only 48kHz is
allowed. Currently the sample rate is selected by the native rate of
the active JACK server. I highly recommend that you use a buffer size of at least 1024
when using AC3JACK, otherwise the CPU usage will be higher than necessary due to the block processing required for AC3 frames.

The channels options will make the following input ports with each
given channel count:

If the -t (--jack-transport) option is used, ac3jack will only write
to the output when the JACK Transport state is Rolling. This is useful
in order to do port connection before the streaming
begins, or to synchronize AC-3 stream capture to disk.
If extra arguments are added to the end of the command
line, they are treated as JACK ports to connect to the
inputs (in channel orders shown above).

Output to File

ac3jack_cli -o file.ac3

This will create the ac3jack client with 5 inputs, (L,R,C,LS,RS) to which you can connect with your favorite JACK patchbay
(eg. qjackctl). It will create an AC-3 stream and the output will be
written to the file specified. As mentioned above, the -t option can
be useful here.

Real-time output to surround receiver via SPDIF

The following command line can be used to send the AC3 stream through
your audio interface (sound card) SPDIF output.

ac3jack_cli -S

This will create the ac3jack client with 5 inputs, (L,R,C,LS,RS) to which you can connect with your favorite JACK patchbay
(eg. qjackctl). The -S option to ac3jack_cli causes it to try to open the
SPDIF portion of your sound card for raw output and send the stream
through it.

Some sound cards may not allow the SPDIF to be accessed when JACK is
using it. In this case, to do realtime streaming you must either have
two sound cards, with JACK running on one, and the -C <card_num>
option to specify the audio interface to open the SPDIF output on.
Alternatively, if you have a multichannel interface that exposes the
SPDIF outputs on specific channels, you can use the Raw JACK Out
option to have ac3jack send the raw spdif PCM output to two JACK ports
that you can connect to your SPDIF channels using a JACK patchbay.

This option is also for audio interfaces that have SPDIF but don't
advertise AC3 passthrough to the OS or that don't allow its use
simultaneously with JACK. You must connect the L and R ports to a
pair of hardware channels that route to the SPDIF output.

WARNING! Do NOT connect these jack ports to analog channels with
speakers attached, or damage might occur! It is wise to keep your
target receiver muted until it locks on the AC3 stream.

All of the options for outputting encoded AC3 via SPDIF or Jack ports are available from the GUI as well.

The older 0.1.2 version of AC3Jack is now deprecated but its page and description is available here.