Saturday, May 24, 2014

Bit Perfect Audio in Ubuntu

Your operating system, music player, and sound card all work together to process the audio on your computer. While these settings are helpful, the processing of your audio by these devices often leads to distortion and a degradation in quality. Setting up bit perfect audio playback ensures that your audio goes directly to your preferred digital to analog converter (DAC) without alterations; giving you the best possible sound reproduction from your system.


I recently picked up a Schiit Stack for my desktop. Being impulsive, I bought it before I really knew how to setup bit perfect audio in Linux. After a lot of research and a bit of frustration, I found a few viable methods for setting bit perfect audio in Ubuntu.

Ubuntu and many distributions use PulseAudio to pass audio from applications and your hardware. As a burgeoning audiophile I don't really like that it re-samples the audio it processes. If you would like to get bit perfect audio with Pulse, I found an excellent guide that walks your through the steps. But I don't feel that that method is suitable for what I wanted to do on my system and requires more CPU and RAM usage. I wanted a simple and elegant solution for sending my audio stream directly to my DAC and let the  Modi process my audio.

In order to do this I used Advanced Linux Sound Architecture (ALSA) and Gmusicbrowser. The setup and configuration is incredibly easy and only involves a couple of terminal commands (highlighted in blue).


I'm using Xubuntu 14.04 but this guide will work in any Ubuntu/Debian derivative and many modern GNU/Linux distributions.

For non Ubuntu users you need to make sure the necessary ALSA tools are installed (change the sudo apt-get command with whatever is appropriate for your distribution) 
sudo apt-get install alsa alsa-utils

Install gmusicbrowser:
sudo apt-get install gmusicbrowser

Install the correct codecs for mp3, flac, ogg
sudo apt-get install gstreamer0.10-plugins-ugly flac libvorbis0a



This guide installs all the necessary dependencies for stock gmusicbrowser installs and audio playback. Consult the gmusicbroswer site for additional plugin dependencies

List Your audio devices/sound card
a play -l


As you can see my Schiit Modi DAC is listed as card: 1


Alternatively you can use alsa-mixer to find your audio device, once you enter the command press F6 to list your sound card


Now start gmusicbrowser and navigate to Settings>Audio:

Change output device to: alsa

Then click on advanced options 
Enter the correct sound card for your device, use the formula hw:X,0 replacing the X with your prefered sound card. For my DAC I entered hw:1,0

I really enjoy this setup, my audio plays from gmusicbrower without being touched and everything else plays through my speakers.

You can use other music players in Linux to achieve bit perfect playback in Linux, I also like DeaDBeef. Head-Fi user Rizlaw did an excellent write up other music players and his guides inspired this post.

Additionally you can also set VLC to use ALSA to send your audio directly to your DAC. You can find the Audio configuration setting under under Tools>Preferences.

Set Output module to ALSA audio output
And Devices to The Name of Your DAC, USB Audio Direct Hardware