# UD-503 mpd alsa config bit perfect

> Bit-perfect Teac UD-503 playback on Debian: remove PulseAudio, then the exact ALSA asound.conf and MPD mpd.conf for a direct hardware output.

- URL: https://guillaumeplayground.net/ud-503-mpd-alsa-config-bit-perfect/
- Author: Guillaume (https://guillaumeplayground.net/about/)
- Published: 2016-01-11
- Updated: 2017-01-10
- Section: Computing & hacking
- Topics: dac, debian, alsa, mpd, teac, ud-503
- Source: Guillaume playground

First of all, kill pulseaudio, burn it, it is useless for pure audio playback.  
Everything else, like kodi, with a hdmi audio output for example, will still work.

In debian:

```
# apt-get remove --purge pulseaudio
# apt-get install mpd alsa-utils alsa-tools
```

Now you have a clean straight mpd -> alsa.  
You should have recompile the [snd-usb-audio](https://guillaumeplayground.net/teac-ud-503-ud-501-snd-usb-audio-patch/) before.

Check your devices:

```
# aplay -l
**** List of PLAYBACK Hardware Devices ****
...
card 2: UD503 [UD-503], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
...
```

Alsa config: /etc/asound.conf

```
pcm.!default { type hw card UD503 }
ctl.!default { type hw card UD503 }
```

MPD config: /etc/mpd.conf

```
pid_file            "/var/run/mpd/pid"
state_file          "/var/lib/mpd/state"

# My nas target / NFS mount
# DB is also remote because it is generated one time for multiple players
# You can keep it local as default
music_directory     "/nas/music"
playlist_directory  "/nas/music/playlists"
db_file             "/nas/music/tag_cache"
log_file            "/nas/music/mpd.log"
sticker_file        "/nas/music/sticker.sql"

# ... root, i don't care. it's a dedicated player but it's bad.
# if you care, keep 'mpd' or any system user in 'audio' group
user                "root"
group               "root"

bind_to_address     "any"
log_level           "default"

save_absolute_paths_in_playlists  "yes"
metadata_to_use           "artist,album,title,track,name,genre,date,disc"
follow_inside_symlinks    "yes"

zeroconf_enabled          "yes"
zeroconf_name             "player"

# Gigabit network, go for it
buffer_before_play      "100%"
connection_timeout      "60"
max_connections         "200"
max_playlist_length     "16384"
max_command_list_size   "2048"
max_output_buffer_size  "8192"
filesystem_charset      "UTF-8"
id3v1_encoding          "UTF-8"

audio_output {
  type      "alsa"
  # default is our single asound device
  device    "default"
  name      "UD503"
  use_mmap  "yes"
  # bit perfect
  auto_resample   "no"
  auto_channels   "no"
  auto_format     "no"
  # Since UD-503 have an integrated preamp, disable mixer completely, Yes!
  mixer_type      "disabled"
  # Good bandwidth
  period_time "50000"
  buffer_time "2500000"
  # And DSD!
  dsd_usb         "yes"
}

input {
  plugin "curl"
}

decoder {
  plugin "dsdiff"
  enabled "yes"
}
```

You can go further with a RT kernel to achieve ultra low latency like i did:  
[RT Kernel](https://rt.wiki.kernel.org/index.php/Main_Page)  
– Linux kernel 4.1.15  
– patch usb-snd-audio  
– patch RT

– a batch of ‘chrt’ to focus RT latency on USB irq and MPD.  
– [pmqos\_static](http://git.fedorahosted.org/cgit/tuned.git/tree/libexec/pmqos-static.py?h=1.0) cpu\_dma\_latency=0

More links:  
– [Linux audio System Configuration](http://wiki.linuxaudio.org/wiki/system_configuration)  
– [Linux Audio](http://wiki.linuxaudio.org/wiki/real_time_info) all realtime info

Bye
