I needed a new sound card for Ubuntu that would allow me to do some recording and playback easily. After a bit of searching and testing, I figured I would go with the Focusrite Scarlett 2i2, which is a USB sound card with 2 XLR + jack inputs, stereo monitor output and a headphone jack. It also supports +48V phantom power if you need to connect a condenser microphone.
In addition it appears to be well-tested on Linux, with several user reporting that the device just works.
However, the device seemed to have some trouble with PulseAudio, which is the default audio library used in Ubuntu. Everything works, meaning that any audio application was able to output sound, and recording in Audacity gave good sound quality, but whenever I started playback or recording after switching between applications, the sound card would hang for 2 seconds and make 4 popping sounds before returning to normal operation.
The solution: JACK + PulseAudio JACK Sink
If you are going to do any serious recording in Ubuntu, or Linux in general, you should get to know JACK. It is an awesome audio library for Ubuntu that aims to make life easy for musicians, audio engineers or the occasional amateur that wants to do recordings. It runs on top of ALSA, meaning it will support almost any sound card you can think of, but does so in a way that gives you extremely low latency and doesn’t mess with sound quality. The downside? JACK doesn’t allow PulseAudio to play side-by-side with it. And every Ubuntu application tries to play through PulseAudio by default.
The solution is to install the pulseaudio-module-jack package, which will allow applications to connect to JACK, even when they have no support for JACK:
sudo apt-get install pulseaudio-module-jack
In addition, you should install a nice GUI that will allow you to control JACK easily. This is named QjackCtl:
sudo apt-get install qjackctl
After installing, just run QjackCtl from the command line or the Dash and start + connect to the JACK server.
After this is done, you may check the Connect window to see if PulseAudio JACK Sink is also running, which it should do by default.
Then you may open Ubuntu’s Sound Settings and set PulseAudio JACK Sink to be your Output device. From now on, all applications should work even though JACK is running.
If you wish to, you may change QjackCtl’s settings to make JACK start whenever QjackCtl is started, and afterwards add QjackCtl to your Startup Applications in Ubuntu. This way JACK will start whenever you start your computer.
No more popping
After installing PulseAudio JACK Sink and QjackCtl, I no longer experience any popping, and the FocusRite Scarlett 2i2 works flawlessly. The sound quality is great and the latency minimal, so I would definitely recommend this sound card to any Linux user wanting to do some recording at home or on the go.
Even though I wish it would work right out of the box, installing two packages to get everything perfect is that much work, and I assume that someone figures out a good solution to merge PulseAudio and JACK in a way similar to the one I use by default sometime in the future.