Personal tools

Difference between revisions of "Jack"

From Rivendell Wiki

Jump to: navigation, search
m (Configuring Rivendell to use JACK: Add note about restarting Rivendell when making JACK Settings changes.)
m (Update links from "http" to "https". Verified links.)
 
(21 intermediate revisions by 3 users not shown)
Line 1: Line 1:
The [https://jackaudio.org/ Jack Audio Connection Kit] (JACK) is a suite of professional, low-latency tools for routing digital audio.
+
The [https://jackaudio.org/ Jack Audio Connection Kit] (JACK) is a suite of professional-grade, low-latency tools for routing digital audio.
  
== Configure Rivendell 3 For Use With JACK ==
+
== Configure Rivendell 3 or 4 For Use With JACK ==
 +
 
 +
This has been confirmed to work with Rivendell 4 and Ubuntu 22.04.3 LTS - 2/1/24 kw
  
 
=== Overview ===
 
=== Overview ===
  
In 2020, Rivendell processes and JACK processes must be run as the same user ID. And since Rivendell processes (in the packaged version available from [[Paravel Systems - USA|Paravel Systems]]) '''''always''''' run as ''root'', this means ''jackd''(8) (the JACK daemon) must also run as ''root''.
+
You have a several choices for getting audio out of a Rivendell system. Notably Rivendell supports [https://alsa-project.org/ ALSA], the native Linux audio subsystem, and JACK, a layer above ALSA.
 +
 
 +
JACK enables multiple audio applications to simultaneously access audio devices on Linux systems.
 +
 
 +
With Rivendell 3.x there are two ways to run JACK.  By default Rivendell processes and JACK processes must be run as the same user ID. And since Rivendell processes (in the packaged version available from [[Paravel Systems - USA|Paravel Systems]]) '''''always''''' run as ''root'', this means ''jackd''(8) (the JACK daemon) must also run as ''root''.
 +
 
 +
The other way to run JACK is in Promiscuous mode.  When ''jackd''(8) (the JACK daemon) is run in promiscuous mode then Rivendell can start jackd as ''root'' and as long as the logged in user is a member of the audio group, then any JACK processes run under the logged in user will also see the JACK server.  With Rivendell V3 accomplishing this requires a few minor modifications to configuration files.  With Rivendell V4 this is the default Jack behavior.
 +
 
 +
== Enabling Promiscuous Mode on Rivendell V3 ==
 +
 
 +
'''Note that this is NOT necessary if you are running Rivendell V4 as it defaults to run in promiscuous mode.  It is only needed with V3.'''
 +
 
 +
Setting up promiscuous mode on Rivendell V3 requires the creation of an environment variable file, and adding that variable to Systemd's Rivendell.service file.
 +
 
 +
First create the following file:
 +
 
 +
sudo nano /etc/profile.d/rivendell-env.sh
 +
 
 +
And then copy / paste into the file:
 +
#
 +
# Run jackd(1) in promiscuous mode
 +
#
 +
export JACK_PROMISCUOUS_SERVER=audio
 +
 
 +
You also need to add a line to your rivendell.service file:
 +
 
 +
sudo nano /lib/systemd/system/rivendell.service
 +
 
 +
and add the line '''Environment=JACK_PROMISCUOUS_SERVER=audio''' to the '''[Service]''' section of the file:
 +
 
 +
[Service]
 +
LimitNOFILE=4096
 +
Type=simple
 +
ExecStart=/usr/local/sbin/rdservice
 +
PrivateTmp=false
 +
Restart=always
 +
RestartSec=2
 +
StartLimitInterval=120
 +
StartLimitBurst=50
 +
Environment=JACK_PROMISCUOUS_SERVER=audio
 +
 
 +
Save the file, and run a:
 +
 
 +
sudo systemctl daemon-reload
 +
 
 +
You will also need to make sure that the logged in user is part of the audio group.  From a shell:
 +
 
 +
  usermod -a -G audio **user**
 +
 
 +
where **user** is the logged in user.  Once you have made the various changes the easiest way to ensure all the updates are picked up is to reboot the system.
  
 
=== Configuring Rivendell to use JACK ===
 
=== Configuring Rivendell to use JACK ===
 +
 +
Prior to configuring JACK, ensure that your computer has the following packages installed: zsh, zita-ajbridge, jackd (no real time when prompted), jacktools (added 2/1/24 kw - Ubuntu 22.04.3 LTS)
  
 
So, you’ve decided to use JACK for your Rivendell audio. First, make sure you tell Rivendell to '''not''' use any ALSA devices on your computer using the [[RDAlsaConfig]] Rivendell app. Run this app from the Rivendell menu and simply unhighlight all devices in the list, as shown here:
 
So, you’ve decided to use JACK for your Rivendell audio. First, make sure you tell Rivendell to '''not''' use any ALSA devices on your computer using the [[RDAlsaConfig]] Rivendell app. Run this app from the Rivendell menu and simply unhighlight all devices in the list, as shown here:
Line 15: Line 68:
 
:(As an aside, when you use JACK for Rivendell’s audio routing, you can also use any other [https://jackaudio.org/applications/ JACK-enabled audio app] alongside Rivendell.)
 
:(As an aside, when you use JACK for Rivendell’s audio routing, you can also use any other [https://jackaudio.org/applications/ JACK-enabled audio app] alongside Rivendell.)
  
:(Another aside: know that Rivendell works well using both JACK clients and [http://www.audioscience.com/ Audio Science] adapters.)
+
:(Another aside: know that Rivendell works fine using both JACK clients and [https://www.audioscience.com/ Audio Science] adapters.)
  
 
Set up JACK on a per-host basis by modifying the configuration in [[RDAdmin]]->[[RDAdmin#Manage_Hosts|Manage Hosts]]->''hostname''. In the host configuration window, touch the '''JACK Settings''' button to manage the Jack settings.
 
Set up JACK on a per-host basis by modifying the configuration in [[RDAdmin]]->[[RDAdmin#Manage_Hosts|Manage Hosts]]->''hostname''. In the host configuration window, touch the '''JACK Settings''' button to manage the Jack settings.
  
Ensure that Rivendell starts the JACK app by checking the '''Start JACK Server''' checkbox. Leave the '''JACK Server Name''' set to ''(default)'' as shown here:  
+
Ensure that Rivendell starts the JACK app by checking the '''Start JACK Server''' checkbox. Unless you have a ''really'' good reason to change it (beyond the scope of this article), leave the '''JACK Server Name''' set to ''(default)'' as shown here:  
  
 
[[Image:Jack-clients-3.4.1.png|center|thumb|440px|border|Configured JACK Clients in Reivendell 3.4.1]]
 
[[Image:Jack-clients-3.4.1.png|center|thumb|440px|border|Configured JACK Clients in Reivendell 3.4.1]]
Line 54: Line 107:
 
export QT_GRAPHICSSYSTEM_CHECKED=1
 
export QT_GRAPHICSSYSTEM_CHECKED=1
  
exec /usr/bin/jackd --name default -d dummy -r 48000 2>&1 > /var/tmp/jackd.log
+
exec /usr/bin/jackd --name default -d dummy -r 48000 2>&1 > /var/tmp/jackd.log</nowiki>
</nowiki>
+
  
 
Copy the above text and save it in a file named <tt>/usr/local/bin/jackd-start</tt>. Make the file executable with <tt>sudo chmod +x /usr/local/bin/jackd-start</tt>. Enter the full path of the shell script into the '''JACK Command Line''' text box.
 
Copy the above text and save it in a file named <tt>/usr/local/bin/jackd-start</tt>. Make the file executable with <tt>sudo chmod +x /usr/local/bin/jackd-start</tt>. Enter the full path of the shell script into the '''JACK Command Line''' text box.
 +
Ensure that the sample rate in the above script matches the sample rate in Rivendell Admin > System Settings
  
 
When using the above script, notice that we initialize JACK with a ''&ldquo;dummy&ldquo;'' device. We do this because the default device name is always ''&ldquo;system&rdquo;''. Not only is this a useless name, it is also something one cannot change without editing the JACK source code. In the above script, we assign the ''&ldquo;dummy&rdquo;'' device to the ''&ldquo;system&rdquo;'' JACK client in order to &ldquo;get it out of the way&rdquo;. We then use ''jack-plumbing'' or some other means to connect JACK client inputs and outputs.
 
When using the above script, notice that we initialize JACK with a ''&ldquo;dummy&ldquo;'' device. We do this because the default device name is always ''&ldquo;system&rdquo;''. Not only is this a useless name, it is also something one cannot change without editing the JACK source code. In the above script, we assign the ''&ldquo;dummy&rdquo;'' device to the ''&ldquo;system&rdquo;'' JACK client in order to &ldquo;get it out of the way&rdquo;. We then use ''jack-plumbing'' or some other means to connect JACK client inputs and outputs.
Line 65: Line 118:
 
After configuring Rivendell to start the JACK subsystem, you probably need to also start some JACK clients. Do this by adding each one in the '''JACK Clients to Start''' section (see the figure above for examples).
 
After configuring Rivendell to start the JACK subsystem, you probably need to also start some JACK clients. Do this by adding each one in the '''JACK Clients to Start''' section (see the figure above for examples).
  
You may want to use the ''[https://github.com/opensourceradio/ram/blob/master/usr/local/bin/pmw-jack-setup pmw-jack-setup]'' script (or something like it) to configure your ALSA sound devices to work with JACK. This script accepts two parameters: the name of the ALSA device to configure, and the &ldquo;human-readable&rdquo; name of the JACK client. You can learn your ALSA device names by running the command <tt>sudo aplay -l</tt> (or <tt>su - root -c 'aplay -l'</tt>) in a terminal window. Running this command results in output like:
+
If you are running Rivendell V4 or have set up promiscuous mode on Rivendell V3 (as described above) then you should be able to start JACK Clients your Linux desktop and they should be able to see the Jackd server.  If there are clients you always want to have started then it is best to have Rivendell start them up.
 +
 
 +
You might consider using the ''[https://github.com/opensourceradio/ram/blob/master/usr/local/bin/pmw-jack-setup pmw-jack-setup]'' script (or something like it) to configure your ALSA sound devices to work with JACK. This script accepts two parameters: the name of the ALSA device to configure, and the &ldquo;human-readable&rdquo; name you want to give the JACK client. You can learn your ALSA device names by running the command <tt>sudo aplay -l</tt> (or <tt>su - root -c 'aplay -l'</tt>) in a terminal window. Running this command results in output like:
  
 
  <nowiki>
 
  <nowiki>
Line 74: Line 129:
 
card 0: Intel [HDA Intel], device 1: CX20561 Digital [CX20561 Digital]
 
card 0: Intel [HDA Intel], device 1: CX20561 Digital [CX20561 Digital]
 
   Subdevices: 1/1
 
   Subdevices: 1/1
   Subdevice #0: subdevice #0
+
   Subdevice #0: subdevice #0</nowiki>
</nowiki>
+
  
 
In the above output, the device name for ''card 0'' is <tt>Intel</tt>. Many people prefer more appropriate names for their JACK devices. One common name for the built-in sound device (the &ldquo;sound card&rdquo; on the PC&lsquo;s motherboard) is ''&ldquo;Onboard&rdquo;''. Set up your first '''JACK Client''' in '''RDAdmin''' as follows:
 
In the above output, the device name for ''card 0'' is <tt>Intel</tt>. Many people prefer more appropriate names for their JACK devices. One common name for the built-in sound device (the &ldquo;sound card&rdquo; on the PC&lsquo;s motherboard) is ''&ldquo;Onboard&rdquo;''. Set up your first '''JACK Client''' in '''RDAdmin''' as follows:
  
 
:* touch '''Add'''
 
:* touch '''Add'''
:* enter a meaningful description in the '''Description''' text box
+
:* enter a meaningful description in the '''Description''' text box; experience (and observing the [https://github.com/ElvishArtisan/rivendell/blob/master/cae/cae_jack.cpp source code]) has shown that the JACK Clients are started in the alpha-numeric order of the '''Description''' label. Use this knowledge to guide your choices of descriptions
 
:* enter the path and parameters to the setup script: <tt>/usr/local/bin/pmw-jack-setup Intel Onboard</tt> in the '''Command Line''' text box
 
:* enter the path and parameters to the setup script: <tt>/usr/local/bin/pmw-jack-setup Intel Onboard</tt> in the '''Command Line''' text box
 
:* touch '''OK''' to save your settings
 
:* touch '''OK''' to save your settings
  
Repeat the above steps for as many ALSA-compatible hardware audio devices as you want to use with Rivendell. Note that ''pmw-jack-setup'' merely configures your hardware audio devices for use with JACK. It does not connect them to Rivendell.
+
Repeat the above steps for as many ALSA-compatible hardware audio devices as you want to use with Rivendell. Note that ''pmw-jack-setup'' merely configures your hardware audio devices for use with JACK. It does not connect them to Rivendell. Also note that using ''pmw-jack-setup'' requires that you also download and install the &ldquo;helper script&rdquo;, ''[https://github.com/opensourceradio/ram/blob/master/usr/local/bin//zsh-functions zsh-functions]'' in ''/usr/local/bin''. ''zsh-functions'' in turn may also require the installation of additional packages.
 +
 
 +
The version of ''pmw-jack-setup'' on github attempt to discern the number of input and output channels for the ALSA device. You can override this with the <tt>--ci ''NUM-CHANNELS''</tt> (capture channels) and <tt>--co ''NUM-CHANNELS''</tt> (playback channels) options, where ''NUM-CHANNELS'' is the actual number of input and output channels you want to use.
 +
 
 +
As with <tt>/usr/local/bin/jackd-start</tt>, be sure to set the permissions on ''pmw-jack-setup'' with <tt>sudo chmod +x /usr/local/bin/pmw-jack-setup</tt>.
  
 
==== Connecting JACK Inputs and Outputs ====
 
==== Connecting JACK Inputs and Outputs ====
Line 90: Line 148:
 
Once you have successfully configured Rivendell to launch JACK and configure your audio devices, you need to &ldquo;connect&rdquo; the devices to Rivendell. There are several ways to do this, including:
 
Once you have successfully configured Rivendell to launch JACK and configure your audio devices, you need to &ldquo;connect&rdquo; the devices to Rivendell. There are several ways to do this, including:
  
:* run one or more Rivendell [http://opsguide.rivendellaudio.org/html/chapter.rml.html Macros] to make the connections (see [http://opsguide.rivendellaudio.org/html/sect.rml.commands.html#sect.rml.connect_jack_ports__jc_ JC])
+
:* run one or more Rivendell [https://opsguide.rivendellaudio.org/html/chapter.rml.html Macros] to make the connections (see [https://opsguide.rivendellaudio.org/html/sect.rml.commands.html#sect.rml.connect_jack_ports__jc_ JC])
 
:* run a JACK plumbing service daemon such as ''jack-plumbing'' to automate the connections
 
:* run a JACK plumbing service daemon such as ''jack-plumbing'' to automate the connections
 
:* run the command line ''jack_connect'' application to make the connections
 
:* run the command line ''jack_connect'' application to make the connections
 
:* use a graphical tool such as [https://qjackctl.sourceforge.io/ qjackctl] or [https://drobilla.net/software/patchage patchage] to make the connections
 
:* use a graphical tool such as [https://qjackctl.sourceforge.io/ qjackctl] or [https://drobilla.net/software/patchage patchage] to make the connections
  
The most reliable methods for making JACK connections are those that perform the work automatically and in the background. Unfortunately, CentOS does not package the ''jack-plumbing'' command, so one must either download the source code from the [[wikipedia:Debian_Linux|Debian]] website: [http://deb.debian.org/debian/pool/main/j/jack-tools/jack-tools_20131226.orig.tar.bz2 here] or [http://deb.debian.org/debian/pool/main/j/jack-tools/jack-tools_20131226-1.debian.tar.gz here] and compile it (the original source code for ''jack-plumbing'' seems to have been lost in the bit bucket), or choose a different &ldquo;plumbing&rdquo; tool to manage the JACK connections.
+
The most reliable methods for making JACK connections are those that perform the work automatically and in the background. Unfortunately, CentOS does not package the ''jack-plumbing'' command, so one must either download the source code from the [[wikipedia:Debian_Linux|Debian]] website: [https://deb.debian.org/debian/pool/main/j/jack-tools/jack-tools_20131226.orig.tar.bz2 here] or [https://deb.debian.org/debian/pool/main/j/jack-tools/jack-tools_20131226-1.debian.tar.gz here] and compile it (the original source code for ''jack-plumbing'' seems to have been lost in the bit bucket), or choose a different &ldquo;plumbing&rdquo; tool to manage the JACK connections.
  
 
Here is an example of a configuration file for ''jack-plumbing''. Note that the &ldquo;comment character&rdquo; is a semicolon (&ldquo;&#59;&rdquo;) rather than the more common hash symbol (&ldquo;&#35;&rdquo;). In general, the ''jack-plumbing'' '''''connect''''' statement format is <tt>(connect "source" "destination")</tt>.  If you place this in ''/etc/jack-plumbing'' you can start the app with simply ''/bin/jack-plumbing'' (see the figure above):
 
Here is an example of a configuration file for ''jack-plumbing''. Note that the &ldquo;comment character&rdquo; is a semicolon (&ldquo;&#59;&rdquo;) rather than the more common hash symbol (&ldquo;&#35;&rdquo;). In general, the ''jack-plumbing'' '''''connect''''' statement format is <tt>(connect "source" "destination")</tt>.  If you place this in ''/etc/jack-plumbing'' you can start the app with simply ''/bin/jack-plumbing'' (see the figure above):
Line 110: Line 168:
 
(connect "rivendell_0:playout_0L" "Onboard:playback_1")
 
(connect "rivendell_0:playout_0L" "Onboard:playback_1")
 
(connect "rivendell_0:playout_0R" "Onboard:playback_2")
 
(connect "rivendell_0:playout_0R" "Onboard:playback_2")
 +
; If your sound card has multiple outputs such as the Focusrite Scarlet 4i4, Rivendell can access the second set of outputs with (uncomment):
 +
;(connect "rivendell_0:playout_1R" "Onboard:playback_3")
 +
;(connect "rivendell_0:playout_2R" "Onboard:playback_4")
  
 
; Connect the first Rivendell input port to the Onboard card.
 
; Connect the first Rivendell input port to the Onboard card.
Line 146: Line 207:
 
; client name "glass".
 
; client name "glass".
 
;(connect "calf:multibandlimiter_out_l" "glass:input_1")
 
;(connect "calf:multibandlimiter_out_l" "glass:input_1")
;(connect "calf:multibandlimiter_out_r" "glass:input_2")
+
;(connect "calf:multibandlimiter_out_r" "glass:input_2")</nowiki>
 
+
</nowiki>
+
  
 
=== Restart Rivendell Service ===
 
=== Restart Rivendell Service ===
Line 154: Line 213:
 
After making changes to your JACK configuration in Rivendell you must restart the Rivendell service. Do this by either rebooting your Rivendell computer, or running the following command in a terminal window:
 
After making changes to your JACK configuration in Rivendell you must restart the Rivendell service. Do this by either rebooting your Rivendell computer, or running the following command in a terminal window:
  
  <nowiki>
+
  <nowiki>sudo systemctl restart rivendell.service</nowiki>
sudo systemctl restart rivendell.service
+
</nowiki>
+
  
 
== Future Work ==
 
== Future Work ==
Line 162: Line 219:
 
To do: make JACK work with [https://www.freedesktop.org/wiki/Software/PulseAudio/ PulseAudio].
 
To do: make JACK work with [https://www.freedesktop.org/wiki/Software/PulseAudio/ PulseAudio].
  
In mid 2020 the [https://pipewire.org/ pipewire] audio subsystem is maturing and aims to be compatible with and to eventually replace both the PulseAudio and the JACK audio systems. Pipewire may include more &ldquo;plumbing&rdquo; tools over the long run.
+
This is complete as of April, 2021: <del>To do: in ''pmw-jack-setup'': use data in ''/proc/asound'' to automatically discern the number of input and output channels for ALSA devices.</del>
 +
 
 +
In 2021 the [https://pipewire.org/ pipewire] audio subsystem is maturing and aims to be compatible with and to eventually replace both the PulseAudio and the JACK audio systems. Pipewire may include more &ldquo;plumbing&rdquo; tools over the long run.

Latest revision as of 02:32, 17 April 2024

The Jack Audio Connection Kit (JACK) is a suite of professional-grade, low-latency tools for routing digital audio.

Configure Rivendell 3 or 4 For Use With JACK

This has been confirmed to work with Rivendell 4 and Ubuntu 22.04.3 LTS - 2/1/24 kw

Overview

You have a several choices for getting audio out of a Rivendell system. Notably Rivendell supports ALSA, the native Linux audio subsystem, and JACK, a layer above ALSA.

JACK enables multiple audio applications to simultaneously access audio devices on Linux systems.

With Rivendell 3.x there are two ways to run JACK. By default Rivendell processes and JACK processes must be run as the same user ID. And since Rivendell processes (in the packaged version available from Paravel Systems) always run as root, this means jackd(8) (the JACK daemon) must also run as root.

The other way to run JACK is in Promiscuous mode. When jackd(8) (the JACK daemon) is run in promiscuous mode then Rivendell can start jackd as root and as long as the logged in user is a member of the audio group, then any JACK processes run under the logged in user will also see the JACK server. With Rivendell V3 accomplishing this requires a few minor modifications to configuration files. With Rivendell V4 this is the default Jack behavior.

Enabling Promiscuous Mode on Rivendell V3

Note that this is NOT necessary if you are running Rivendell V4 as it defaults to run in promiscuous mode. It is only needed with V3.

Setting up promiscuous mode on Rivendell V3 requires the creation of an environment variable file, and adding that variable to Systemd's Rivendell.service file.

First create the following file:

sudo nano /etc/profile.d/rivendell-env.sh

And then copy / paste into the file:

#
# Run jackd(1) in promiscuous mode
#
export JACK_PROMISCUOUS_SERVER=audio

You also need to add a line to your rivendell.service file:

sudo nano /lib/systemd/system/rivendell.service

and add the line Environment=JACK_PROMISCUOUS_SERVER=audio to the [Service] section of the file:

[Service]
LimitNOFILE=4096
Type=simple
ExecStart=/usr/local/sbin/rdservice
PrivateTmp=false
Restart=always
RestartSec=2
StartLimitInterval=120
StartLimitBurst=50
Environment=JACK_PROMISCUOUS_SERVER=audio

Save the file, and run a:

sudo systemctl daemon-reload

You will also need to make sure that the logged in user is part of the audio group. From a shell:

 usermod -a -G audio **user**

where **user** is the logged in user. Once you have made the various changes the easiest way to ensure all the updates are picked up is to reboot the system.

Configuring Rivendell to use JACK

Prior to configuring JACK, ensure that your computer has the following packages installed: zsh, zita-ajbridge, jackd (no real time when prompted), jacktools (added 2/1/24 kw - Ubuntu 22.04.3 LTS)

So, you’ve decided to use JACK for your Rivendell audio. First, make sure you tell Rivendell to not use any ALSA devices on your computer using the RDAlsaConfig Rivendell app. Run this app from the Rivendell menu and simply unhighlight all devices in the list, as shown here:

RDAlsaConfig Ready for JACK
(As an aside, when you use JACK for Rivendell’s audio routing, you can also use any other JACK-enabled audio app alongside Rivendell.)
(Another aside: know that Rivendell works fine using both JACK clients and Audio Science adapters.)

Set up JACK on a per-host basis by modifying the configuration in RDAdmin->Manage Hosts->hostname. In the host configuration window, touch the JACK Settings button to manage the Jack settings.

Ensure that Rivendell starts the JACK app by checking the Start JACK Server checkbox. Unless you have a really good reason to change it (beyond the scope of this article), leave the JACK Server Name set to (default) as shown here:

Configured JACK Clients in Reivendell 3.4.1

It is easiest to set the JACK Command Line to the full path of a shell script so you can make changes to the way in which the JACK app is started.

Note that regardless of how you configure the JACK Command Line if you make any changes to the JACK Settings you must restart the Rivendell service, interrupting audio playout, in order for the changes to take effect. Plan your changes accordingly.

Here is an example JACK startup script:

#!/bin/sh

#######################################################################
##
## This script is started by Rivendell caed when the Rivendell daemons
## are launched. The script assumes a "default" Rivendell installation
## with the username 'rd' automatically logged in and running the
## windowing system.
##
## Change the JACK sample rate to match your Rivendell sample rate
## set in RDAdmin->System Settings.
##
#######################################################################

export LANG=en_US.UTF-8
export TERM=xterm
export QTDIR=/usr/lib64/qt4
export PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/home/rd/bin
export XDG_DATA_DIRS=/usr/local/share/:/usr/share/
export XDG_RUNTIME_DIR=/run/user/1000
export QT_GRAPHICSSYSTEM_CHECKED=1

exec /usr/bin/jackd --name default -d dummy -r 48000 2>&1 > /var/tmp/jackd.log

Copy the above text and save it in a file named /usr/local/bin/jackd-start. Make the file executable with sudo chmod +x /usr/local/bin/jackd-start. Enter the full path of the shell script into the JACK Command Line text box. Ensure that the sample rate in the above script matches the sample rate in Rivendell Admin > System Settings

When using the above script, notice that we initialize JACK with a “dummy“ device. We do this because the default device name is always “system”. Not only is this a useless name, it is also something one cannot change without editing the JACK source code. In the above script, we assign the “dummy” device to the “system” JACK client in order to “get it out of the way”. We then use jack-plumbing or some other means to connect JACK client inputs and outputs.

Adding JACK Clients

After configuring Rivendell to start the JACK subsystem, you probably need to also start some JACK clients. Do this by adding each one in the JACK Clients to Start section (see the figure above for examples).

If you are running Rivendell V4 or have set up promiscuous mode on Rivendell V3 (as described above) then you should be able to start JACK Clients your Linux desktop and they should be able to see the Jackd server. If there are clients you always want to have started then it is best to have Rivendell start them up.

You might consider using the pmw-jack-setup script (or something like it) to configure your ALSA sound devices to work with JACK. This script accepts two parameters: the name of the ALSA device to configure, and the “human-readable” name you want to give the JACK client. You can learn your ALSA device names by running the command sudo aplay -l (or su - root -c 'aplay -l') in a terminal window. Running this command results in output like:

**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: CX20561 Analog [CX20561 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: CX20561 Digital [CX20561 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

In the above output, the device name for card 0 is Intel. Many people prefer more appropriate names for their JACK devices. One common name for the built-in sound device (the “sound card” on the PC‘s motherboard) is “Onboard”. Set up your first JACK Client in RDAdmin as follows:

  • touch Add
  • enter a meaningful description in the Description text box; experience (and observing the source code) has shown that the JACK Clients are started in the alpha-numeric order of the Description label. Use this knowledge to guide your choices of descriptions
  • enter the path and parameters to the setup script: /usr/local/bin/pmw-jack-setup Intel Onboard in the Command Line text box
  • touch OK to save your settings

Repeat the above steps for as many ALSA-compatible hardware audio devices as you want to use with Rivendell. Note that pmw-jack-setup merely configures your hardware audio devices for use with JACK. It does not connect them to Rivendell. Also note that using pmw-jack-setup requires that you also download and install the “helper script”, zsh-functions in /usr/local/bin. zsh-functions in turn may also require the installation of additional packages.

The version of pmw-jack-setup on github attempt to discern the number of input and output channels for the ALSA device. You can override this with the --ci NUM-CHANNELS (capture channels) and --co NUM-CHANNELS (playback channels) options, where NUM-CHANNELS is the actual number of input and output channels you want to use.

As with /usr/local/bin/jackd-start, be sure to set the permissions on pmw-jack-setup with sudo chmod +x /usr/local/bin/pmw-jack-setup.

Connecting JACK Inputs and Outputs

Once you have successfully configured Rivendell to launch JACK and configure your audio devices, you need to “connect” the devices to Rivendell. There are several ways to do this, including:

  • run one or more Rivendell Macros to make the connections (see JC)
  • run a JACK plumbing service daemon such as jack-plumbing to automate the connections
  • run the command line jack_connect application to make the connections
  • use a graphical tool such as qjackctl or patchage to make the connections

The most reliable methods for making JACK connections are those that perform the work automatically and in the background. Unfortunately, CentOS does not package the jack-plumbing command, so one must either download the source code from the Debian website: here or here and compile it (the original source code for jack-plumbing seems to have been lost in the bit bucket), or choose a different “plumbing” tool to manage the JACK connections.

Here is an example of a configuration file for jack-plumbing. Note that the “comment character” is a semicolon (“;”) rather than the more common hash symbol (“#”). In general, the jack-plumbing connect statement format is (connect "source" "destination"). If you place this in /etc/jack-plumbing you can start the app with simply /bin/jack-plumbing (see the figure above):

; JACK port connection rules.
; See man jack-plumbing for details.
; dklann@broadcasttool.com, Fri Aug 14 09:20:55 PDT 2020

; Connect the first Rivendell output port to the Onboard card.
; See also pmw-jack-setup and the JACK client name for the
; built-in audio device. Substitute your audio device for
; "Onboard" as necessary...
(connect "rivendell_0:playout_0L" "Onboard:playback_1")
(connect "rivendell_0:playout_0R" "Onboard:playback_2")
; If your sound card has multiple outputs such as the Focusrite Scarlet 4i4, Rivendell can access the second set of outputs with (uncomment):
;(connect "rivendell_0:playout_1R" "Onboard:playback_3")
;(connect "rivendell_0:playout_2R" "Onboard:playback_4")

; Connect the first Rivendell input port to the Onboard card.
(connect "Onboard:capture_1" "rivendell_0:record_0L")
(connect "Onboard:capture_2" "rivendell_0:record_0R")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Audio processing with Calf plugins
; Use this along with calfjackhost to connect some Calf audio
; plugins for real-time audio processing.
;
; Rivendell Primary output to BassEnhancer
;(connect "rivendell_0:playout_0L" "calf:bassenhancer_in_l")
;(connect "rivendell_0:playout_0R" "calf:bassenhancer_in_r")
; -or- Rivendell Primary output to MultibandCompressor input
;(connect "rivendell_0:playout_0L" "calf:multibandcompressor_in_l")
;(connect "rivendell_0:playout_0R" "calf:multibandcompressor_in_r")
; MultibandCompressor output to Limiter input
;(connect "calf:multibandcompressor_out_l" "calf:multibandlimiter_in_l")
;(connect "calf:multibandcompressor_out_r" "calf:multibandlimiter_in_r")

; BassEnhancer output to MultibandCompressor input
;(connect "calf:bassenhancer_out_l" "calf:multibandcompressor_in_l")
;(connect "calf:bassenhancer_out_r" "calf:multibandcompressor_in_r")

; MultibandCompressor output to MultibandLimiter input
;(connect "calf:multibandcompressor_out_l" "calf:multibandlimiter_in_l")
;(connect "calf:multibandcompressor_out_r" "calf:multibandlimiter_in_r")

; MultibandLimiter output to Onboard input
;(connect "calf:multibandlimiter_out_l" "Onboard:playback_1")
;(connect "calf:multibandlimiter_out_r" "Onboard:playback_2")

; Limiter output to glasscoder input
; This assumes you are running GlassCoder with the JACK
; client name "glass".
;(connect "calf:multibandlimiter_out_l" "glass:input_1")
;(connect "calf:multibandlimiter_out_r" "glass:input_2")

Restart Rivendell Service

After making changes to your JACK configuration in Rivendell you must restart the Rivendell service. Do this by either rebooting your Rivendell computer, or running the following command in a terminal window:

sudo systemctl restart rivendell.service

Future Work

To do: make JACK work with PulseAudio.

This is complete as of April, 2021: To do: in pmw-jack-setup: use data in /proc/asound to automatically discern the number of input and output channels for ALSA devices.

In 2021 the pipewire audio subsystem is maturing and aims to be compatible with and to eventually replace both the PulseAudio and the JACK audio systems. Pipewire may include more “plumbing” tools over the long run.