Configuring MPD for Bit Perfect Playback with an external DAC

Bit Perfect sound is sending the exact bits from a sound file typically to an external Digital Analogue Converter (DAC) without re-sampling. Both Windows and Linux by default send all audio through a general re-sampler. On Windows XP the sampler is known as KMixer(1) and in Linux with ALSA it is known as Dmix(2). In Windows XP you can use WASAPI, Kernel Streaming or ASIO. In ALSA you can configure Dmix to handle all kinds of settings by configuring ‘plugs’ that are set up to support a particular sampling rate.

A greatly preferred method of playing audio is to set up an MPD server for the following reasons:

  • Low system resources (Can run on a wall plug computer(3))
  • Headless installation (Can be controlled via a tablet or phone through the network)
  • Handles incredibly large databases of music (4.3 TiB and counting in my setup)
  • Highly Configurable (as we read below)

I have a couple configurations for MPD depending on the device location. This particular one is for a machine that I use at the office, the Precision 5400 has a terrible internal DAC/AMP setup that actually makes squealing noises that vary depending on what I am performing on my machine. I purchased a portable USB/RCA DAC (NuForce Icon uDAC2) that I can carry with me in my laptop bag or headphone case. At home I use a different DAC but you will see, the same technique applies.

I will warn you from the start, we will be manually specifying the audio device in MPD, this will give exclusive access to that resource to MPD so your other sound emitting softwares may not work. This can even cause hangs in software such as flash, to get around this. I specify the output device in Gnome to be different than my digital output device and use another set of headphones.

Firstly, lets install mpd and a nice controller for it (GMPC):

sudo apt-get install mpd gmpc

Now lets figure out what our audio devices are:

aplay –list-devices

This gives me an output that looks like this:

storrgie@enceladus:~$ aplay –list-devices
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: AD198x Analog [AD198x Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: AD198x Digital [AD198x Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: N2 [NuForce µDAC 2], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: N2 [NuForce µDAC 2], device 1: USB Audio [USB Audio #1]
Subdevices: 1/1
Subdevice #0: subdevice #0

You can see I have two distinct cards, first (0) is the Intel onboard card which actually supports a digital interface and the second (1) is the NuForce uDAC 2 (I’m not sure why you see two subdevices) which is connected via USB. I am using USB because this is a portable solution, at home I use S/PDIF output from an Intel on board controller currently (ALC888). I am considering purchasing a card based on the C-Media 8738/8768 chips (4). You can test your card using the ‘speaker-test’ application which is typically included with ALSA.

Now you need to edit your mpd.conf, there are a couple ways to set up MPD (whether you choose to keep the config in your home directory or set it up for the entire machine via /etc/mpd.conf) but I will be choosing to set it up for my entire machine as I treat this as a single user system.

sudo nano /etc/mpd.conf

You can read through all of the config and set up what is necessary, I’ll concentrate on the Audio Output. You see the default audio output looks something like this:

audio_output {
type “alsa”
name “My ALSA Device”
device “hw:0,0″
format “44100:16:2″
}

You will want to make something similar to this, specify the device only and still use ALSA and you will be doing bit-perfect output to the digital interface:

audio_output {
type “alsa”
name “NuForce uDAC2″
device “hw:1,0″
}

Notice I simply just changed the device card number to 1, which I see from running the aplay –list-devices above.

Enjoy!

Hardware:

It is important to select a card that can perform bit perfect audio, I am currently experimenting with my Intel HDA

References:

1: Windows Legacy Audio Components
2: Dmix ALSA Wiki
3: Dreamplug (S/PDIF interface)
4: C-Media 8738/8768 Open Source Drivers

 

7 Responses to “Configuring MPD for Bit Perfect Playback with an external DAC”

  1. Jyrki says:

    Awesome!
    Your instructions made a BIG difference in sound! Now my Ubuntu gives bitperfect.

    Thanks!

  2. Serge says:

    Thanks for your blog,

    I am trying to use MPD on my laptop. I use Ubuntu 10.10 with a USB Dac, the Nuforce Icon HDP. I followed your instruction (and others).

    MPD is working on laptop speakers but not through the dac.

    Any help would be welcome.

    Thanks

    Serge

  3. Serge says:

    Oops it works when writing Nuforce istead of Nu Force in the etc/mpd.conf

    Thanks

  4. mark says:

    Oops, the problem is the blog software, it seems unable to show that as dash dash list-devices or else the comment code parses it wrong.

  5. Jon says:

    aplay –list-devices. So useful.

  6. Angelo says:

    I have an Arcam USB DAC, but here the hw address keeps changing. Sometimes after a restart it 0,0 and other times it is 1,0. No other devices are used. Any ideas?

  7. Mark S. says:

    Serge: RE: post #3
    I’m confused about your problem, the “name” field in the mpd.conf is completely arbitrary (you should be able to set it to any string you want). In my case, I wanted two stanzas for my DAC, one for software mixer and one for hardware. So I made two mpd.conf stanzas, one with the mixer_type “software” and another “hardware”. I used the name “Stello DAC hw” and “Stello DAC sw” so I could easily select the one I wanted from gmpc with the device menu. My name strings had nothing to do with any magic string in my Stello Dac that had to be matched. The idea is that software mode allows easy volume control from gmpc but hardware mixer is supposed to be more accurate (it’s bit perfect)

    Mark s.

Leave a Reply