MPD (Music Player Daemon) is a player that leverages a client/server architecture, which allows the user to control it remotely using the various clients available for it. It is a great choice for those users that are looking for a minimalist yet powerful tool to listen to and control their audio files.
Contents
Configuration
On installation, the package creates an init service to launch it at startup. The configuration is done in the /etc/mpd.conf file.
Launch as user
The service is started by root. It is best to start MPD as a user. To start it as user "foo", add to mpdconf:
user "foo"
You can also deactivate the service, either by editing /etc/default/mpd:
START_MPD = false
either by deactivating the service:
# update-rc.d -f mpd remove
In this case, the configuration is done in the file ~ / .mpdconf.
Paths
You have to define different paths to be able to use mpd:
- music_directory: folder where the music/audio files are located;
- playlist_directory: folder where the playlists are located;
- db_file: database file;
- log_file: log file;
- error_file: error log file.
- pid_file: file containing the pid (to be able to properly close the program)
For example :
music_directory "~ / Music" playlist_directory "~ / .mpd / playlists" db_file "~ / .mpd / mpd.db" log_file "~ / .mpd / mpd.log" error_file "~ / .mpd / mpd.error" pid_file "~ / .mpd / mpd.pid"
Remember to create the folders if necessary.
Audio output
Alsa simple
To be able to play the sound via alsa, you must add a section in mpdconf:
audio_output { type "alsa" name "my ALSA device" }
You also have to define the mixer. For example, to use PCM:
mixer_type "alsa" mixer_device "default" mixer_control "PCM"
Alsa with separate mixer
You can also define a “virtual” mixer to control the volume of MPD separately. To do this, you must create a /etc/asound.conf file:
# the sound card pcm.real { hw type card 0 device 0 } # the ipc stuff is needed for permissions, etc. pcm.dmixer { dmix type ipc_key 1024 ipc_perm 0666 slave.pcm "real" slave { period_time 0 period_size 1024 buffer_size 8192 spleen 44100 } bindings { 0 0 1 1 } } ctl.dmixer { hw type card 0 } # software volume pcm.softvol { softvol type slave.pcm "dmixer" control { name "Software" card 0 } } # mpd volume control pcm.mpdvol { softvol type slave.pcm "dmixer" control { name "MPD" card 0 } } # ctrl for mpd volume ctl.mpdvol { hw type card 0 } # input pcm.input { dsnoop type ipc_key 3129398 ipc_key_add_uid false ipc_perm 0660 slave.pcm "810" } # duplex device pcm.duplex { asym type playback.pcm "softvol" capture.pcm "input" } # default devices pcm.! default { plug type slave.pcm "duplex" } # for oss devices pcm.dsp0 { plug type slave.pcm "duplex" }
Then, in mpdconf, we define the Alsa output, as well as the mixer
# Alsa output: audio_output { type "alsa" name "Alsa Software Volume" device "mpdvol" "44100: 16: 2" format # optional } # Mixer: mixer_type "alsa" mixer_device "mpdvol" mixer_control "MPD"
You can also use other audio devices (OSS, ESD, Jack, PulseAudio). The configuration is detailed in the mpd wiki: http://mpd.wikia.com/wiki/Configuration#Audio_Outputs
Other options
You can set a password for certain functions:
password "XXXX @ read, add, control, admin"
If you have problems with accents in filenames, add:
filesystem_charset "UTF-8"
Other options exist, you will find a detailed configuration file in /usr/share/doc/mpd/mpdconf.example.
Usage
You must first launch the server. If you are using the init service:
/etc/init.d/mpd restart
Otherwise, as a user:
mpd
A separate client is needed to control MPD. A few of them are listed below:
- mpc: command line client (very useful for making launchers, keyboard shortcuts or scripts);
- ncmpc: a simple console client;
- ncmpcpp: a clone of ncmpc with some additional options (advanced search, tag editing, ...);
- sonata: a very good customer in GTK;
- ario: a client
- gmpc: a graphical client for Gnome.
There are many others: http://mpd.wikia.com/wiki/Clients
Internet radio usage
MPD can be controlled remotely. But it can also source service for a ?ShoutCast or Icecast server. To install an Icecast server: http://www.andesi.org/admin:installer-un-serveur-icecast
Then just define an additional audio output for the Icecast server:
audio_output { type "shout" name "example.org" host "localhost" port "8000" mount "/mpd.ogg" password "XXXXXX" quality "5.0" # bitrate "128" "44100: 16: 1" format user "source" # description "My Stream Description" # optional # genre "jazz" # optional # public "no" # optional }
With:
- name: name of the Icecast server;
- host: name or IP of the Icecast server (localhost, if it is on the same machine);
- passwd: the password defined for the source in the Icecast configuration.
- quality or bitrate: only one of the two must be defined
- description, genre and audience: additional information that will appear in the audio player that plays the stream.
Warning: If you do not configure any other output (alsa, for example), you will probably have an "cannot open mixer" error message. You just need to create a "null" output to remedy the problem:
audio_output { type "ao" "null" driver name "Dummy output" }
If you have a web server with php support, you can use clients like phpMp +: http://mpd.wikia.com/wiki/Client:PhpMpplus So you can control MPD remotely using a simple browser.