User:DominiqueMichel/ALSA:JACK audio connection kit
Backup of ALSA#JACK_audio_connection_kit, 2024 10 29
JACK audio connection kit
It is possible to interconnect JACK and ALSA. At that time of writing, the best solution and it look like to be the final one, is via the snd-loopback module and the jack ALSA plugin. For that, see JACK#ALSA - Bridging ALSA and JACK together. See JACK — describes the setup of a playing sound with JACK (JACK Audio Connection Kit)..
What follow is a general introduction to JACK, some parts of it can be outdated.
Jack provides an additional layer, to the already low latency ALSA drivers and applications, and further it guarantees a constant sound latency and synchronous operation of all its clients. Jack can only use one sound card at a time, and will provide separated outputs and inputs for each audio channel of the sound card. Jack further provides the ability to view, manipulate or pipe audio streams, both hardware and software streams, in a similar manner we use cables to interface different audio equipment. As example, JAMin can intercept an audio stream before exporting the stream to another audio application and/or through analog or S/PDIF outputs. The Jack user owned daemon, is usually started using qjackctl. The qjackctl utility provides many other functions including audio stream connections.
What Jack does not do, is handle A/52 encoded (AC-3 or Dolby/DTS) material on input; it is just a sound server that deal with separated channels of audio streams. And it has the capability to connect simultaneously and synchronously any output stream on any input, and any input to any output stream, that on any hardware and software audio component, and with a constant latency. This make JACK an outstanding tool for audio production and creation. The ac3jack tool can be used for encoding multiple separated audio channels to AC-3 streams.
When playing an A/52 encoded media, the player will request as many outputs from JACK than audio channels in the media. This will fail if your sound card doesn't have the requested amount of audio outputs, but will be fine otherwise. As example, you can use mplayer as usual, and configure it to output a 5.1 stream on a 7.1 output configuration, or a 7.1 stream on a 2 channels stereo output.
One solution is to configure your kernel and ALSA according to Jack installation instructions for providing low latency audio. Since ALSA is said to be already very efficient and low latency, providing very good quality playback with no additional mixing when stated within its .asoundrc file, unlike MS Windows, Jack probably isn't needed for most. The main audience of JACK is audio producers and musicians (in studio, live performances, DJ, ...). The proaudio-gentoo overlay is available with eselect-repository.
For an older solution using the zita-ajbridge, see Using an ALSA Loopback device and zita-ajbridge on the ProAudio Gentoo overlay wiki.
Using zita-ajbridge, it is also possible to add additional real sound cards into JACK. (Example needed)
Those who want to try JACK must know one thing: You will need a realtime kernel and rt operations only if you want to make a Digital Audio Workstation (DAW) with your computer, which necessitate something pulseaudio is not able to achieve: constant sound latency as low or lower than 20 msec (pulseaudio is not able to provide constant sound latency at all), and synchronous operations. JACK can also be an alternative to pulseaudio for an user that want a professional solution, see JACK#ALSA - Bridging ALSA and JACK together.