FANDOM


== Before configuring ==
Music Player Daemon will look for configuration files in two default places. The system-wide configuration file can be found at /etc/mpd.conf. For local users, mpd will find it at ~/.mpdconf. You can specify a configuration file with launching mpd by issuing mpd /PATH/TO/FILE/my_config_file. When launching a second command with a different configuration file, you can have multiple instances of mpd running. Make sure you have installed mpd. The default configuration file should be of great help.

If you would have any problems in starting mpd after configuration, this is most likely due to permission problems. Music Player Daemon will also perfectly run without any audio output set up.

The Manual maintained by the developers can be found here.


Initial Configuration Edit

After installation, MPD won't work until you tell it where the media files are. You do that by changing the ~/.mpdconf file (for individual users) or /etc/mpd.conf for system-wide MPD. You may want to start with this:

<br />port            "6600"<br />music_directory         "~/music"<br />playlist_directory      "~/.mpd/playlists"<br />db_file                 "~/.mpd/mpd.db"<br />log_file                "~/.mpd/mpd.log"<br />
You will need to create the directories if they do not already exist, e.g.:
<br />mkdir -p ~/.mpd/playlists<br />

For those using linux, if you have a samba server with all your music, say that its share name is ALBUMS, and you mount it locally as /mnt/albums. Then have your db_file option to point at such place, i.e. /mnt/albums. This way, when you don't have the ALBUMS share mounted on your computer you will have your mpddb file with LOCAL files (note that the mount destination should be ~/music as well), whereas when you have it mounted you will have your mpddb file with all your music. Note that this will not require creating mpddb files each and every time (just need to run /etc/init.d/mpd restart)

== Additional options ==
The default config file, which is distributed with mpd, should guide you through some additional options. You can adjust what someone connected through a client can do, the amount of messages put in the log file, et cetera.

== Audio Outputs ==
mpd serves a wide variety to get the audio to multiple places in a multitude of ways. You can enable multiple outputs at the same time, for example in a multiple zone setup, or to stream the same output both to your amplifier, to some kinda service on your computer, and a stream to the internet. By default, every audio output you configured is enabled after you start, but inserting enabled = "no" leaves it off by default. You can later enable this output with a client.

Later versions of mpd may support Generic Decoders to decode files and streams.

Local Playback Edit

Linux comes with multiple, partially overlapping ways of dealing with audio. Most (all?) of these possibilities of outputting audio are supported by mpd. To get an overview of the several services and options there are, please read Linux Audio Explained

==== Alsa ====
With Alsa you can send the audio output directly to your sound card. By default, this will be the device hw:0,0, which corresponds to one audio output on your sound card. A typical configuration is:

audio_output { <br />       type                    "alsa"<br />       name                    "My ALSA Device"<br />       device                  "hw:0,0"     # optional<br />       format                  "44100:16:2" # optional<br />}

If you want to plug your amplifier in another hole in your soundcard, you will have to figure out how to address a specific physical connection on your sound card, or if you want to make use of the digital output, please see the specialized Alsa HOWTO.


PulseAudio Edit

PulseAudio seems to become the default sound server in more and more linux distributions. It has some advantages over Alsa, such as the capability to stream the output to a server over the network, or volume control over the sources of the audio, and the ability to flexibly put an audio stream to another sink.

To make use of PulseAudio with mpd, you just need to add a new audio_output section with the type set to "pulse". You can also specify a server and sink parameter. A typical audio_output section looks like this:

<br />audio_output {<br />      type    "pulse"<br />      name    "My MPD PulseAudio Output"<br />      #server  "localhost"   # optional<br />      #sink    "alsa_output" # optional<br />}

Fur Distributions like Ubuntu 10.4, network access must be enabled; This can be done in the "System / Preferences / PulseAudio Preferences" menu after installing the paprefs package. See the PulseAudio HOWTO for more options and how to escape some errors.

JACK Edit

===== libao / JACK =====
Check out the instructions at the alsa-project.org website on how to set up an ALSA device that forwards to JACK, then simply set this device as your output device in mpd.conf. Actually it seems to work only for the "ao" output type using the "alsa09" driver:

audio_output {    
   type        "ao"    
   driver      "alsa09"    
   options     "dev=devicename" # replace devicename with that of your .asoundrc without the leading 'pcm.'    
                                # (i.e. "dev=jackplug", when you set up pcm.jackplug in your .asoundrc)    
   name        "Jack Output"    
}

native / JACK Edit

Here is how to use jack in more recent versions of mpd:

audio_output {       
      type    "jack"       
      name    "my jack device"     
}


Enlightened Sound Daemon / EsounD / ESD Edit

The Enlightened Sound Daemon, or ESD, intercepts and mixes digital
audio streams before passing them to /dev/dsp, thereby letting
multiple sound sources have simultaneous access to the sound hardware.
MPD relies on libao, the cross-platform audio library, and, happily for
ESD users, libao supports ESD.

Configuration to let libao, ESD, and MPD work together can be done
in either of two ways. The libao configuration file,
/etc/libao.conf, sets the default libao sound driver, using the syntax
default_driver=x, where x is an available driver. As of version 0.8.5,
the drivers are oss, esd, arts, alsa, alsa09, nas, irix, and
sun. Setting a system-wide libao default with default_driver=esd should
do the trick. Alternatively, the MPD configuration file /etc/mpd.conf
can also specify the libao ESD driver as follows:
driver "esd". This overrides the libao default and works equally
well.

If you want to play your music on another host (perhaps becuase the computer with the speakers doesn't have enough hard drive space for your music), this seems to work:

<br />audio_output {<br />      type      "ao"<br />      driver    "esd"<br />      options   "host=jurp5-desktop:16001" <br />      name      "esd"<br />}
ESD not working in Ubuntu Edit
If the ESD output doesn't work in Ubuntu, you might try setting the following lines in /etc/esound/esd.conf:
<br />auto_spawn=1<br />spawn_options=-noterminate -nobeeps -as 5<br />

OSS Edit

MPD includes support for OSSv3. OSS4 will work, except for the mixer.
<br />audio_output {<br />      type      "ao"<br />      name      "My OSS Device"<br />      driver    "oss"<br />#        device      "/dev/dsp" # optional<br />#        format      "44100:16:2" # optional<br />#        mixer_device   "/dev/mixer" # optional, does not work with OSS4<br />#        mixer_control  "mix" # optional, does not work with OSS4<br />}
==== FIFO Output ====
The fifo plugin writes raw PCM data to a FIFO (First In, First Out) file.  The data can be read by another program. Available from mpd 0.14. Example config:
<br />audio_output {<br />      type                    "fifo"<br />      name                    "My FIFO"<br />      path                    "/tmp/mpd.fifo"<br />}

==== MacOS ====
To enable the audio output in MacOS, you need to define the type of the "audio_output" as "osx". Example config:

<br />audio_output {<br />      type            "osx"<br />      name            "My Mac Device"<br />      mixer_type      "software"<br />}

==== Windows ====
To enable the audio output in Windows, you need to define the type of the "audio_output" as "winmm". Example config:

<br />audio_output {<br />      type            "winmm"<br />      name            "My Windows Device"<br />}

In order to have multiple outputs you specify the 'device' option and use multiple audio_output stanzas with unique names:

<br />audio_output {<br />      type            "winmm"<br />      name            "Speakers"<br />      device          "Speakers (Realtek High Definition Audio)"<br />}

audio_output {<br />      type            "winmm"<br />      name            "SPDIF"<br />      device          "Realtek Digital Output (Realtek High Definition Audio)"<br />}

The properly formatted device name can be discovered in Windows 7 by opening the volume mixer and activating the 'device' drop-down. That list of devices contains exactly what needs to be specified in 'device'.

Remote Playback Edit

IceCast Edit

MPD can stream to an IceCast (or other ShoutCast compatible) server. The following instructions assume that you have your IceCast server working and setup correctly. First grab the latest version of MPD from svn. (Note: version 0.11.5 and earlier, does not support streaming to a ShoutCast server! Check your install by running /usr/bin/mpd --version to see if shout is listed as an output format).

Sidenote: Since MPD 0.15 there is a built-in alternative to using IceCast. See below for more information.

===== Installation =====
You install it by using:

<br />./autogen.sh --prefix=/path/to/dir<br />make<br />make install (this command may need root priveleges depending on the prefix chosen)<br />
Once you have mpd installed from svn, you just have to edit your MPD config file (the default is at /etc/mpd.conf), or in the prefix that you chose during installation. Make sure that you have something like the following section in your config file:
<br />################# SHOUT STREAMING ########################<br />#
# Set this to allow mpd to stream its output to icecast2<br /># (i.e. mpd is a icecast2 source)<br />#
audio_output {<br />      type              "shout"<br />      name              "my cool stream"<br />      host              "localhost"<br />      port              "8000"<br />      mount             "/mpd.ogg"<br />      password          "IceCast_mpd"<br />      quality           "5.0"   <br />#       bitrate           "64"<br />      format            "44100:16:1"

# Optional Parameters<br />     user            "source"<br />#       encoding        "mp3" # ogg by default<br />#       description     "here's my long description"<br />#       genre           "jazz"<br />} # end of audio_output<br />##########################################################<br />

The lines above that start with a "#" are comment lines. The other lines have the following meaning:

  • type "shout" indicates that this output is to be streamed to a ShoutCast server.
    * name "my cool stream" sets the title of the stream, that your listeners will see.
    * host "localhost" is the hostname of the Shoutcast server. If the server does not run on the same machine as MPD, change this accordingly.
    * port "8000" is the port number on the server that MPD should connect to.
    * mount "/mpd.ogg" is the path from the server root where your stream will be broadcast. In this example, the URL of the stream will be http://localhost:8000/mpd.ogg.
    * password "IceCast_mpd" is the password used to broadcast on the server. Change this to the password required by your IceCast server.
    * quality "5.0" OR bitrate "64" set the quality of your stream. You can (and must) only set one of them. quality is for variable bitrate Ogg/Vorbis, and bitrate for constant bitrate. Quality 3 is the default for oggenc and sounds little better than a mp3 at 128 kbits.
    * format "44100:16:1" is the audio format of the stream. The first number is the sample rate in Hertz (Hz); 44100 Hz is equal to cd quality. The second number is the number of bits per sample; again 16 bits is the quality used on cd's. The third number is the number of channels; 1 channel is mono, 2 channels is stereo. So x:x:1 will mix a stereo channel down to a mono channel.
    * user "source", description "here's my long description" and genre "jazz" set some metadata that will be added to the headers of your stream and can be viewed by listeners.
    * Add protocol parameter to change streaming protocol from icecast2 to "shoutcast" or "icecast1"
Supported Output Formats Edit

Currently only OggVorbis is supported in mainline; MP3 is supported from version 0.14, with the optional parameter "encoding".

See also Edit

Wikipage on Icecast2 configuration

Jonathan Fors' guide on MPD/Icecast streaming

FreeBSD MPD/Icecast setup

==== Built-in HTTP streaming ====
Since version 0.15 there is a built-in HTTP streaming deamon/server that comes with MPD. To activate this server simply set it as output device in mpd.conf:

audio_output {    
 type        "httpd"    
 name        "My HTTP Stream"    
 encoder        "vorbis"        # optional, vorbis or lame    
 port        "8000"    
#    quality        "5.0"            # do not define if bitrate is defined    
 bitrate        "128"            # do not define if quality is defined    
 format        "44100:16:1"    
}

Then to listen to this stream simply open the URL of your mpd server (along with the specified port) in your favorite music player. Note: You may have to specify the file format of the stream using an appropriate file extension in the URL. For example in my case, using Winamp 5.5, I had to use http://192.168.178.5:8000/mpd.ogg rather than http://192.168.178.5:8000/.

Sidenote: In my (subjective) experience it seems that the CPU usage is much lower when using the built-in http streaming server than when using IceCast. And since I use MPD 24/7 this actually makes a difference.

Use mpd to connect to the stream
You can also connect to this stream with mpd from another computer. See for a howto and some tricks here.

Another sidenote: After updating to MPD 0.16, my httpd output was broken until I added the following :
bind_to_address "0.0.0.0"