QjackCtl and PulseAudio for IDJC part 2

Automated Full-feature startup for JACK for regular usage of JACK and IDJC loaded in one click

Information following on from previous article part 1

see Part 3 for Automated single-click startup of JACK for regular general usage.

This is a full-featured setup to start QjackCtl with Pulseaudio connections for VOIP and AUX and also:

  • Custom names for connections
  • Set audio connection defaults in PulseAudio
  • Start IDJC

Reasons for using custom names in PulseAudio:

Default PulseAudio to JACK connections (PulseAudio Jack Sink / Pulseaudio Jack Source) can be a problem for use with terminal commands and bash scripts. every command has to be edited to add “\” before each text space to be interpreted correctly:

jack_disconnect PulseAudio\ JACK\ Sink:front-left system:playback_1

To add more Pulseaudio connections command: pactl load-module-jack-sink adds a connection “Pulseaudio Jack Sink 01”; then “Pulseaudio Jack Sink 02” and so on. The lack of distinctive naming for connections is not important in normal circumstances, but is very helpful if a problem needs to be located and resolved during a live broadcast.


3.1 Disable Default Pulseaudio connections

Copy Pulseaudio configuration in system folder to home folder for customisation:

cp /etc/pulse/default.pa ~/.config/pulse/default.pa

Open the new file in home folder ~/.config/pulse/default.pa in any text editor

find this section in the configuration and add a “#” comment symbol at the start of each line to disable this part:

### Automatically connect sink and source if JACK server is present
# .ifexists module-jackdbus-detect.so
# .nofail
# load-module module-jackdbus-detect channels=2 connect=no
# .fail
# .endif

you can also delete it, and any other commented line starting with “#”, original file still has default settings

Reboot to restart Pulseaudio using the new custom configuration


3.2 Make script to setup audio connections and start IDJC automatically

Create the script file and make it executable:

echo '#!/bin/bash' > ~/.config/jack/jack_start.sh
chmod 700 ~/.config/jack/jack_start.sh

Open the file in a text editor and copy/paste this script:

#!/bin/bash
#jack_start.sh

#add pulseaudio to jack connections
# load voip sink/source
pactl load-module module-jack-sink sink_name=jack_out client_name=voip_in channels=2 connect=no
pactl load-module module-jack-source sink_name=jack_in client_name=voip_out channels=2 connect=no
# load pulse aux sink
pactl load-module module-jack-sink sink_name=aux_out client_name=aux_in channels=2 connect=no

#set pulseaudio default sink and source
pacmd set-default-source jack_in
pacmd set-default-sink aux_out

#load idjc
/usr/bin/idjc &

save and close script file


3.3 Configure JACK to use bash script

(see part 1 for other settings required in QjackCtl)

add location of bash script file in QjackCtl Options tab “Execute script after startup”:

using ~/.config/jack/jack_start.sh does not work here, must be full path: /home/(your username)/jack/jack_start.sh


3.4 Start Button



3.4 Configure Pulseaudio Connection

This requires JACK has been started to access options for Pulseaudio sinks to JACK

The commands pactl-set-default-sink and pactl-set-default-sink operate correctly with one exception

Audio from VOIP callers is set by default in PulseAudio playback to Aux channels of IDJC, same as all other playback

On first test VOIP call, audio playback stream must be manually changed to “voip_in”

PulseAudio should save the changed setting and further calls should not need manual intervention


4 Additional – Disable PulseAudio ALSA Connection

Although Pulseaudio is generally reliable, some audio streams can still try to connect direct to ALSA. If this is now in use with JACK, the application will stall.

Use this command to find Pulseaudio card number(s) and profiles

pactl list cards

Additional command added to jack_start script turns off ALSA card 0 in PulseAudio:

pactl set-card-profile 0 off

card can be verified as off in `pavucontrol`

Another command is needed after JACK is stopped to turn ALSA connection back on:

pactl set-card-profile 0 output:analog-stereo+input:analog-stereo

Card will show in Pulseaudio configuration as “Analog Stereo Duplex”

Single command (or script with more commands) can be set in QjackCtl “Execute script after Shutdown”