Raspberry Pi MPD setup

Installing Music Player Daemon (MPD) on the Pi is simple

$ sudo apt-get mpd

This will install the binaries, make mpd autostart, add a config file and create the directories under /var/lib/mpd.

The config file at /etc/mpd.conf works out of the box and the core bit of this is a follows

audio_output {
 type "alsa"
 name "My ALSA Device"
 device "hw:0,0" # optional
 format "44100:16:2" # optional
 mixer_device "default" # optional
 mixer_control "PCM" # optional
 mixer_index "0" # optional
 }

Note that by default it uses ALSA.

There are many other posts detailing the process. Here are a few
http://hempeldesigngroup.com/embedded/stories/raspberry-pi-setup-as-mpd-sever/
http://miro.oorganica.com/raspberry-pi-mpd/
http://lesbonscomptes.com/pages/raspmpd.html

Put some music files in /var/lib/mpd/music and it is ready to go.
To actually play music with mpd you need a client to control it, this can be installed using

$ sudo apt-get mpc

To play a song do the following

$ mpc update                        'makes mpd read the music directory
                                    'and update its database
$ mpc listall                       'lists all the music in the database
$ mpc insert ‘album or song name’   'adds something to the playlist
$ mpc playlist                      'prints the playlist
$ mpc play                          'plays the playlist
$ mpc volume 70

MPD can also be controlled by a client on another device. A good remote for the iPhone is MPoD – http://www.katoemba.net/makesnosenseatall/mpod/

This can connect to MPD over the network and browse and play music. You will need to open port 6600 if you have a firewall and ensure that the mpd.conf file has MPD listening to all network addresses. In mpd.conf

bind_to_address     "any"

MPoD also has a means to show cover art, if you have a web server running you can enter a URL where it can find the cover art images. I already have a cover art image stored in each album directory so all I had to do was make the music directory accessible to a browser. I did this by adding it to the apache config as follows

Alias /mpd/ "/media/Store/Media/Music/"
<Directory "/media/Store/Media/Music/">
  Options Indexes FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
  Allow from 192.168.100
</Directory>

One annoying thing is that every time a song starts a pop is heard out of the audio port. This is a Raspberry Pi issue and is because the Pi audio out uses PWM,
See Raspberry Pi MPD audio without the pop and crackle

Using 2013-02-09-wheezy-raspbian.img
MPD pops at song start ‘mpc play’, pops at song end ‘mpc stop’

Update – 5Aug2013.
The lastest version of Raspbian “wheezy” downloaded from the Raspberry Pi website has this issue fixed. Version at the time of writing was 2013-07-26-wheezy-raspbian

Advertisements

One thought on “Raspberry Pi MPD setup

  1. Andreas Rüdel

    hi
    apache has evolved – from 2.4 on your config should read:
    (to allow 10.x.x.x, 192.168.x.x and my ipv6 subnet)

    Alias /mpd /media/Music

    Options Indexes FollowSymLinks
    AllowOverride None
    Require ip 10 192.168 2001:980:xxxx::

    thanks for the tips 🙂

    Andreas

    Reply

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s