Recent changes Random page

Technology
 
Gaming
Entertainment
Science Fiction
Biggest wikis
Hobbies
Music
See more...

Configuration

From Music Player Daemon Community Wiki

Jump to: navigation, search

Contents


[edit] Initial Configuration

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:

port			"6600"
music_directory         "~/music"
playlist_directory      "~/.mpd/playlists"
db_file                 "~/.mpd/mpd.db"
log_file                "~/.mpd/mpd.log"
error_file              "~/.mpd/mpd.error"

[edit] Audio Outputs

[edit] Icecast

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).

You install it by using:

[edit] Installation

./autogen.sh --prefix=/path/to/dir
make
make install (this command may need root priveleges depending on the prefix chosen)

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:

################# SHOUT STREAMING ########################
#
# Set this to allow mpd to stream its output to icecast2
# (i.e. mpd is a icecast2 source)
#
audio_output {
        type              "shout"
        name              "my cool stream"
        host              "localhost"
        port              "8000"
        mount             "/mpd.ogg"
        password          "IceCast_mpd"
        quality           "5.0"   
#       bitrate           "64"
        format            "44100:16:1"

# Optional Parameters
       user            "source"
#       description     "here's my long description"
#       genre           "jazz"
} # end of audio_output
##########################################################

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" and bitrate "64" set the quality of your stream. You can (and must) only set one of them. I suppose that quality is for variable bitrate Ogg/Vorbis, and bitrate for constant bitrate. Can anyone confirm this?
  • 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.
  • 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.

[edit] Supported Output Formats

Currently only OggVorbis is supported.

[edit] See also

Jonathan Fors' guide on MPD/Icecast streaming

FreeBSD MPD/Icecast setup

[edit] PulseAudio

See the PulseAudio HOWTO.

[edit] 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"
}

[edit] Enlightened Sound Daemon / EsounD / ESD

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:

audio_output {
        type      "ao"
        driver    "esd"
        options   "host=jurp5-desktop:16001" 
        name      "esd"
}

[edit] Permissions Problems

Testing on a Debian GNU/Linux (unstable) system revealed permission problems when ESD version 0.2.35 is used with a standard Debian configuration of MPD version 0.11.5.

First issue: the mpd user does not have the right to execute a shell. Change this by executing (as root):

  # chsh -s /bin/true mpd

Second issue: if you want to be able to connect to spawned esd with other applications, you'll need to add in /etc/esound/esd.conf:

spawn_options=-tcp -public -terminate -nobeeps -as 5

These also can be overcome by changing settings in /etc/mpd.conf so as to relocate MPD's log, state, and database files from /var to a normal user directory, and by changing the default MPD user accordingly. For example, for user dwrob:

# required
playlist_directory "/mnt/peedee/MP3/Playlists"
music_directory    "/mnt/peedee/MP3/Music"
port               "6600"
# log_file         "/var/log/mpd/mpd.log"
log_file           "/home/dwrob/.mpd/mpd.log"
# error_file       "/var/log/mpd/errors.log"
error_file         "/home/dwrob/.mpd/errors.log"

# optional, but HIGHLY RECOMMENDED
#db_file           "/var/lib/mpd/mpddb"
db_file            "/home/dwrob/.mpd/mpddb"

# user             "mpd"
user               "dwrob"

# optional, but recommended
# state_file       "/var/lib/mpd/state"
state_file         "/home/dwrob/.mpd/state"

[edit] ESD not working in Ubuntu

If the ESD output doesn't work in Ubuntu, you might try setting the following lines in /etc/esound/esd.conf:

auto_spawn=1
spawn_options=-noterminate -nobeeps -as 5

[edit] ALSA dmix Output

When you want to allow users to dmix their played sounds to mpd output sound if you run mpd from init scripts you need either to configure ALSA dmix plugin acording this gentoo HOWTO, either don't forget to set the ipc_* stuff well, because without it only root would be able to dmix other sounds.

Sample /etc/asound.conf configuration:

pcm.dmixer { 
    type dmix 
    ipc_key 1024
    ipc_key_add_uid false
    ipc_perm 0666			# mixing for all users
    slave { 
        pcm "hw:0,0" 
        period_time 0 
        period_size 1024 
        buffer_size 8192
        rate 44100
    }
    bindings { 
        0 0 
        1 1 
    } 
} 

pcm.dsp0 { 
    type plug 
    slave.pcm "dmixer" 
} 

pcm.!default { 
    type plug 
    slave.pcm "dmixer" 
} 

pcm.default { 
   type plug 
   slave.pcm "dmixer" 
} 

ctl.mixer0 { 
    type hw 
    card 0 
}


[edit] ALSA MPD software volume control

The following is what is needed to get a working software volume control that can be controlled by alsamixer, as well as the mpd volume control. This allows mpd to be lowered in volume, but not the other sounds on your system (or vice-versa)

[edit] Create asound.conf

First, the following lines are required in /etc/asound.conf. Note the software mixer mpdvol with the name "MPD". This will be used when editing the /etc/mpd.conf file. The software mixer "softvol" controls the level of the other sounds on your computer, and has the generic name of "Software".

# the sound card
pcm.real {
  type hw
  card 0
  device 0
}

# the ipc stuff is needed for permissions, etc.
pcm.dmixer {
  type dmix
  ipc_key 1024
  ipc_perm 0666
  slave.pcm "real"
  slave {
    period_time 0
    period_size 1024
    buffer_size 8192
    rate 44100  
  }
  bindings {
    0 0
    1 1 
  }
}

ctl.dmixer {
  type hw
  card 0
  }

# software volume
pcm.softvol {
  type softvol
  slave.pcm "dmixer"
  control {
    name "Software"
    card 0
  }
}
# mpd volume control
pcm.mpdvol {
  type softvol
  slave.pcm "dmixer"
  control {
    name "MPD"
    card 0
  }
}
# ctrl for mpd volume
ctl.mpdvol {
  type hw
  card 0
}

# input
pcm.input {
        type dsnoop
        ipc_key 3129398
        ipc_key_add_uid false
        ipc_perm 0660
        slave.pcm "810"
}

# duplex device
pcm.duplex {
        type asym
        playback.pcm "softvol"
        capture.pcm "input"
}

# default devices
pcm.!default {
  type plug
  slave.pcm "duplex"
}

# for oss devices
pcm.dsp0 {
  type plug
  slave.pcm "duplex"
}

[edit] Edit mpd.conf

Next, the following lines need to be edited in /etc/mpd.conf:

The device line in the audio_output below should be set to the device name for the mpd volume that was specified above in the asound.conf file. Note that the mixer_device line uses the same device as the device line in the audio_output section, but that the mixer_control line should be set to the NAME that was given in asound.conf.

audio_output {
        type                    "alsa"
        name                    "Alsa Software Volume"
	device			"mpdvol"
}

and

mixer_type                      "alsa"
mixer_device                    "mpdvol"
mixer_control                   "MPD"


You will need to restart the mpd daemon before these settings to work. If they aren't working, you may try rebooting your system. You should see a listing for the volume for MPD using gnome-alsamixer or alsamixer. You can also control the volume setting using any other client for mpd (mpc, ncmpc, gmpc, sonata, etc.). It doesn't affect the other sounds on your system!

[edit] FIFO Output

Currently only svn trunk version supports fifo output. Example config:

audio_output {
        type                    "fifo"
        name                    "My FIFO"
        path                    "/tmp/mpd.fifo"
}

[edit] Generic Decoder Support

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

Rate this article:

Share this article:

.