Running PulseAudio through JACK was very unstable for me. QJackCtl would crash half of the time when trying to connect to PulseAudio.
After some mucking about, I found out how to make it stable. So far, I have experienced ZERO crashes with my new settings (except that one time when Skype had a memory leak and crashed the system). I am posting this tutorial because I want to find out if this will work for others. My explanations are based on my observations. If you know the technical explanation, post in this thread and I'll try to add it to the tutorial. I am running Lucid so I don't know if this tutorial will work for later versions. Also, I don't know whether Jack and Jack2 are similar enough for this to work on the latter.
This tutorial uses content from this Wiki page. However, this tutorial has been modified because the I found the original article's instructions slightly incomplete. I don't have an account on that site so if you do, I encourage you to update it.
WARNING: THE FOLLOWING INSTRUCTIONS INVOLVE SETTING THE VOLUME TO MAXIMUM. PLEASE PAUSE/MUTE/QUIT ALL APPLICATIONS THAT PLAY SOUNDS (SUCH AS MEDIA PLAYERS) BEFORE USING THE FOLLOWING SETTINGS. AFTER PRESSING "START" IN QJACKCTL, LOWER YOUR VOLUME NORMALLY.
TAKE OFF YOUR HEADPHONES. YOU'LL GO DEAF IF YOU FORGET TO LOWER YOUR VOLUME SETTINGS AFTER PRESSING "START".
You have to install JACK in the first place, so...
Code:
sudo apt-get install qjackctl
QJackCtl is a GUI for jackd.
Now you need to install some modules for connecting PulseAudio to JACK:
Code:
sudo apt-get install pulseaudio-module-jack pulseaudio-utils
Now open up QJackCtl and click Setup.
In the configuration window that appears, look for Force 16 bit and tick the box.
You can try unticking it later if you get problems.
Move to the Options tab.
You will see a list of scripts that will run at specified times. Most are empty by default.
Use these settings:
Execute script on startup:
Code:
amixer set Master 100% ; a2jmidid &
"amixer set Master 100%" sets the volume to maximum because for some reason the max volume for the virtual JACK output (more on that in a moment) is your current volume before starting jackd. "a2jmidid &" starts a program in the background. I think it is some sort of bridge for connecting ALSA and JACK MIDI ports. I had it by default so I left it alone.
Execute script after startup:
Code:
sleep 1 ; pactl load-module module-jack-sink channels=2 ; pactl load-module module-jack-source channels=2 ; sleep 1 ; pacmd set-default-sink jack_out ; pacmd set-default-source jack_in
The "pactl load-module module-jack-sink channels=2 ; pactl load-module module-jack-source channels=2" command creates the virtual JACK input and output devices.
The problem with this setup is that it seems the modules are being loaded too soon after starting the jackd server. The solution is "sleep 1". This makes sure that the jackd server has enough time to start up properly. Without it, QJackCtl will crash about 50% of the time when loading the modules.
"pacmd set-default-sink jack_out ; pacmd set-default-source jack_in" sets the new virtual JACK input and output devices as the defaults (it will revert to normal when JACK is shut down). Again, there seems to be a problem where the commands are being run too early. Again, the solution is "sleep 1". Without it, you would have to enter the commands twice before they would take effect.
Execute script on shutdown:
Code:
SINKID=$(pactl list | grep -B 1 "Name: module-jack-sink" | grep Module | sed 's/[^0-9]//g') ; SOURCEID=$(pactl list | grep -B 1 "Name: module-jack-source" | grep Module | sed 's/[^0-9]//g') ; pactl unload-module $SINKID ; pactl unload-module $SOURCEID ; sleep 1
Just to be tidy, this set of commands unloads the PulseAudio-JACK modules before shutting down the jackd server. Also, the "sleep 1" at the end prevents QJackCtl from crashing when you start, stop and start again the jackd server in the same QJackCtl session.
Execute script after shutdown:
This makes sure that all instances of jackd are shut down. This is the default, so no need to change it.
RUNNING JACK USING THE ABOVE-MENTIONED SETTINGS WILL RESULT WITH YOUR VOLUME SET TO MAXIMUM. AFTER PRESSING "START" IN QJACKCTL, LOWER YOUR VOLUME NORMALLY. AGAIN, FAILURE TO FOLLOW THIS WARNING MAY RESULT IN HEARING DAMAGE (AND, POSSIBLY, SPEAKER DAMAGE).
AFTER RUNNING JACK, QUITTING QJACKCTL AFTERWARD WILL STILL LEAVE YOUR VOLUME AT MAXIMUM. LOWER IT UNLESS YOU LIKE HAVING YOUR EARDRUMS BLASTED OUT.
YOU HAVE BEEN WARNED. DON'T BLAME ME IF YOU GO DEAF.
You should be done. To test it, run QJackCtl with the above-mentioned settings and hit Start. Wait until the numbers start to change to make sure jackd has finished starting up. Now open an audio file or video file (except a silent video) in Totem (because Totem is not JACK-compatible by default). You should be able to hear the file now.
EDIT: espeak doesn't seem to work properly while jackd is running. The last few syllables get cut off for me. Then again, who uses espeak for songwriting?
Bookmarks