JACK

This article Article description::describes the setup of a playing sound with JACK (JACK Audio Connection Kit).

JACK is a sound server for professional audio production, that provides low-latency communication for applications that implement the JACK API (like mpv).

Installation
JACK uses ALSA for accessing the sound card hardware, be sure ALSA is working.

There are two implementations of the JACK API, both implementations are considered equivalent. JACK is the original implementation, it uses a C API and has built-in Linux MIDI integration. Whereas JACK2 is a re-implementation in C++ and has support for SMP and DBUS.

Visit "what are the differences between JACK 1 and JACK2" for an in-depth comparison.

JACK2
First, emerge the sound server itself.

USE flag
The global USE flag  enables support for JACK in other packages, so they can submit sound to a JACK server:

The command is part of.

After setting this be sure to update the system so the changes take effect:

Sound Server
JACK can be configured using the utility. A basic configuration script for JACK could look like:

To determine the playback device you want to use instead of, you can use:

GUI
A good JACK configuration and control software is.

Bridging
JACK can route sound which was sent to other sound systems like PulseAudio and ALSA through itself.

PulseAudio
To use PulseAudio's JACK module needs to have the  USE flag enabled.

In order to route all audio from PulseAudio to JACK, the JACK sink needs to be configured:

PulseAudio will recognize that JACK started and will bridge its audio to JACK.

"Cannot use real-time scheduling" error
Some applications may show a permission error when trying to connect to Jack, for example:

Adding the current user to the  group should solve this:

Log out and log back in to apply group change.