MPD + USB + rPI

After months of collecting dust, I didn’t really have anything fun or new to do with a raspberry Pi. Then after some internet inspiration I was drawn to the idea of creating a music server. I’m not sure what brought me to try this with such a small device, but once I had all the parts together, it seemed only right to give it a try.

Parts

Parts:

  • Raspberry Pi (running your favorite Linux OS)
  • USB DAC
  • Phone running: MPDroid
  • some way of connecting your raspberry pi to the same network as your phone

The USB DAC I’m using here I got off of eBay (Muse audio mini-usb DAC). It has worked well with my desktop, netbook, virtual machines, etc. You can configure your Pi to use a wireless usb device or just use an ethernet cable. I’m opting for the latter.

First, you’ll need to put your favorite linux distro on the raspberry pi. Arch linux happens to be my favorite, so the intructions on how to do that can be found here

Once that is installed, boot up the Pi with the USB DAC attached. You’ll need to install mpd.

1
pacman -S mpd

Music Player Daemon (MPD) is a flexible, powerful, server-side application for playing music. Through plugins and libraries it can play a variety of sound files while being controlled by its network protocol.

One of the things I really liked about MPD is the fact that it is very minimum, and lightweight. It’s so lightweight, you’ll need your own client to connect to and control it with. Not to worry though, there are quite a few clients out there.

MPDroid

If you want to control it via command line you’ll need mpc and/or ncmpcpp

1
pacman -S mpc ncmpcpp

Configuration is quite simple.

This particular DAC shows up as:

1
2
user@box:~$ lsusb | grep -i audio
Bus 003 Device 006: ID 08bb:2704 Texas Instruments Audio Codec

The configuration file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# See: /usr/share/doc/mpd/mpdconf.example

user "mpd"
# pid_file "/run/mpd/mpd.pid"
# db_file "/var/lib/mpd/mpd.db"
# state_file "/var/lib/mpd/mpdstate"
log_file "/var/lib/mpd/log"

# playlist_directory "/var/lib/mpd/playlists"
music_directory "/var/lib/mpd/music"
# sticker_file "/var/lib/mpd/sticker.sql"

mixer_type "software"

audio_output {
type "alsa"
name "USB Dac Output"
device "hw:1,0"
format "44100:16:2"
max_clients "0"
}

audio_output {
type "fifo"
name "FIFO"
path "/tmp/mpd.fifo"
format "44100:16:2"
}

Once you have that edited, save it and restart mpd:

1
systemctl restart mpd

The important stuff is uncommented. If mpd does not restart, or it does not start properly, you are most likely missing a directory or file listed above, or mpd does not have correct permissions to access the directories you specified. You can verify this by checking the logs files (which in this case is located at “/var/lib/mpd/log”).

In some cases, mpd chooses not to read /etc/mpd.conf, you can manually specify this file with:

1
mpd /etc/mpd.conf

Now, dump all your music in “/var/lib/mpd/music”. Once you have this upload, you can update the library using the command mpc:

1
mpc update

At this point, you can control the music player daemon using ncmpcpp.

But that’s not really fun/cool. MPDroid is an android application that lets you control your mpd installation. Install that and head to the configuration section. Your raspberry pi and phone will need to be on the same network for this to work. You can leave all the defaults as they are, the only thing you should change is the address of the host instance under “Connection settings” to match the IP of your raspberry Pi (you can find that by running ip a).

Configuration

Once you have that configured you should be able to browse, add, play and queue your music.

Music playing