What is Jack? Well its a pretty useful program if you have a lot of audio input devices (musicians) or several output devices (audiophiles). It also has a nice cross connect setup where you can map each speaker to a source on the system and you can merge them as well. This actually solved one of my *nix issues I had that Pulse was not detecting that I had 5.1 setup and I was only using my front speakers but now with Jack everything is working great!

I have written a very simple shell script that will stop your current pulse audio output module and use the jack module instead. The script also provides a way back to your original setup so you do not need to doanything on the command line when you want to use Jack for any application. This script has several “sleep 10s” commands as Pulse does take a few seconds to die and start up. If you want some extra few seconds you can modify these values or be more patient.

 #! /bin/sh USER_PULSEFILE=~/.pulse/pulse.pa case "$1" in start) echo "Killing current Pulse Audio process..." pkill pulseaudio sleep 10s echo "Restart Pulse Audio process as a daemon..." pulseaudio -nDF $USER_PULSEFILE echo "Wait for the daemon to start..." sleep 10s ;;  modules) echo "Killing current Pulse Audio process..." pkill pulseaudio sleep 10s echo "Restart Pulse Audio process as a daemon..." pulseaudio -D echo "Wait for the daemon to start..." sleep 10s echo "Loading the Jack modules..." pacmd load-module module-jack-sink channels=2 pacmd load-module module-jack-source channels=1 ;;  stop) echo "Killing current Pulse Audio process..." pkill pulseaudio sleep 10s echo "Restart Pulse Audio process..." pulseaudio -D ;;    *) echo "Usage: pulsejack {start|modules|stop}" >&2 exit 1 ;;esac exit 0

save this script via your favorite text editor to your .pulse directory and call it pulsejack. 

eg. Copy the above script and open a terminal and type:

cat > ~/.pulse/pulsejack << "EOF"  *ENTER**Right click > paste*EOF  *ENTER* 

 

Then you will need to make a copy of the default pulse.pa script and remove the udev module as it gets in the way with static modules.

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

 

Open pulse.pa in your favorite editor and comment out the module-udev-detect and if statements like below. Also add the module-jack-sink and source.

Pulseoptions

 

While you are in ~/.pulse/ make a client.conf file and put autospan = no in it or type whats below. This will make sure Pulse does not automatically restart when we run our script.

echo "autospawn = no" > ~/.pulse/client.conf

 

Next you need to actually install Jack and its related parts. A simple apt-get will do what we want. qjackctl is the Jack control panel and does a fantastic job and allows you to do the source/output patching like I mentioned above.

sudo apt-get install jackd pulseaudio-module-jack qjackctl

 

This next step may be optional but I read that it helps out Jack if you have a lot of data moving around the audio system. YMMV but I recommended you do these commands just to be safe. The limits.conf file is used by a hardware management daemon that kills apps when they hog to many resources.

sudo addgroup <username> audiosudo su -c 'echo @audio - rtprio 99 >> /etc/security/limits.conf'sudo su -c 'echo @audio - nice -10 >> /etc/security/limits.conf'sudo su -c 'echo @audio - memlock unlimited >> /etc/security/limits.conf'

 

 

Thats it! You could not run everything by hand if you wanted or you can setup qjackctl to handle the shell stuff for you. To do that open qjackctl and goto “Setup > Options” and set the run and stop scripts up like I have below

Options

 

Now push the start button and your audio manager will show Jack as the default output device!

Jack

Advertisements