Perhaps you've fiddled with Linux sound configuration until you're blue in the face. Perhaps you've flip-flopped between Pulseaudio and Jack because they each did something useful but each also missed something you needed. Perhaps you (too) tried endless .asoundrc config files trying to get ALSA to do what it is you wanted.
There's a better way. Just use Pulseaudio *with* Jack.
Pulseaudio (hereafter PA) has the convenience that everything uses it; Chrome and Ubuntu practically force you to use it. Only some programs support the Jack API but those that do absolutely need it, and besides, you want to use it for its quick hook-up features. You *can* have the best of both worlds.
The following recipe will run PA on top of Jack. Programs that use PA will simply use it. Likewise for Jack. Yet, you will be able to select which sound card to use relatively easily, and you will be able to insert various filters, recorders, etc.
First, add yourself to the audio group:
% sudo usermod -a -G audio $USER
You may have to logout/login to see the effect.
Next, install any packages that you might be missing:
% sudo apt-get install jackd2
% sudo apt-get install pulseaudio-module-jack
% sudo apt-get install patchage
Now to start loading things. There are 2 ways to go about this. One is a fairly light handed way, the other fairly heavy handed. Try both, take your pick.
Both methods require that something useful be in ~/.jackrc. Here is a reasonable default:
% echo /usr/bin/jackd -d alsa > ~/.jackdrc
Jack will grab the first audio device listed by:
% aplay -l
It
can happen that this isn't the system default device. Therefore, it's a good idea to actually specify the device name,
not the number:
% aplay -l
**** List of PLAYBACK Hardware Devices ****
card 2:
PCH [HDA Intel PCH], device 0: ALC262 Analog [ALC262 Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
See how my first device is card 2, not zero(0) ? That's because ALSA found some USB devices first on boot-up. Therefore, my Jack command line is:
/usr/bin/jackd -d alsa -d hw:PCH
Yes, those are 2 "-d" options. The first "-d" tells Jack which back-end to use. Once a back-end is selected, the remaining arguments are sent to that back-end. The second "-d" tells the ALSA back-end which device to grab. Again, I specified the name (in this case, "PCH"), not the number.
Starting Jack
% mkdir ~/.pulse
% cp /etc/pulse/
default.pa ~/.pulse
Then edit ~/.pulse/
default.pa and add:
load module-jack-sink
load module-jack-source
and re-start PA:
% pulseaudio -k
This
should force load jackd, but I have seen Pulseaudio refuse to start the Jack server. If you don't see any Jack devices in the Gnome sound configuration tool, try this:
% pactl load-module module-jack-sink
% pactl load-module module-jack-source
Whichever method you got working, start the Gnome sound configuration tool (pavucontrol might work in non-Ubuntu distros) and select the Jack source for Input, and the Jack sink for output. Set both volumes to 100% and close the config tool.
Next, start up Patchage. In the tool's window, you should see PA's sink connected to "system:playback", and likewise "system:capture" connected to PA's source. By clicking on various connections, you can move or remove them. Play with it. You can't break anything.
If you don't see both the system input
and output, then Jack probably grabbed the wrong device, probably an input-only or an output-only device. See above to specify the actual device.
If you need to add any sound cards (or devices) that aren't listed, you will need to create Jack clients for them. For each *input* device (e.g. microphones), run:
% alsa_in <what-you'd-like-to-call-it> <input-device>
for example:
% alsa_in my-usb-mic hw:2,0 &
For each *output* device, run:
% alsa_out <output-name> <output-device> &
Note the terminating ampersand(&). This will run it in the background. You might need to devote a console to them because they spit out occasional error messages. I like using the program "screen" for this.
Once they are started, you should see blocks representing the new inputs and outputs in Patchage. Connect them to PA's ports if desired (inputs to PA sources, PA sinks to outputs), or connect them directly to the system inputs and outputs (not to themselves, of course.) This flexibility is the beauty of Jack.
You can also install utilities that tweak the sound pretty easily. For instance, zita-at is an auto-tuner, rakarrack is a guitar distortion utilitity, and jack-rack is a general sound tweaker. It can do lots of things including reverb, chorus, mute and amplification. Want to record all your video calls? Just start a Jack recorder (e.g. audacity) and connect it to an output (or PA sink).