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.
First of all install MPD:
apt-get install mpd
It's recommended to install mpc too:
apt-get install mpc
Mpc is a command line based client for MPD that should help you to control it without any special GUI client.
Set up MPD as user service and prevent it to start as a system daemon:
sudo service mpd stop
and
sudo update-rc.d mpd disable
Now we will make a new directory in the home folder for the configuration files of MPD and the playlists:
mkdir -p ~/.mpd/playlists
Copy the configuration file to our home folder:
gunzip -c /usr/share/doc/mpd/examples/mpd.conf.gz > ~/.mpd/mpd.conf
And now we will create all the needed files for it:
touch ~/.mpd/{mpd.db,mpd.log,mpd.pid,mpdstate}
Now is the time when we will actually edit the MPD configuration file. Use your editor of choice:
geany ~/.mpd/mpd.conf
Enter your home directory and your user name. The music_directory has to point to the music folder:
music_directory "/media/David Extern/Música" playlist_directory "/home/david/.mpd/playlists" db_file "/home/david/.mpd/tag_cache" log_file "/home/david/.mpd/mpd.log" pid_file "/home/david/.mpd/mpd.pid" state_file "/home/david/.mpd/mpdstate"
Comment the line which starts with user:
#user "mpd"
The second important thing is your sound output. To use Alsa, edit the section:
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
}
But if you use Pulse, you have to comment the Alsa section and go to the Pulse section and it has to look like this:
audio_output {
type "pulse"
name "MPD"
# server "remote_server" # optional
# sink "remote_server_sink" # optional
}
Save the file and close your editor.
To start MPD just type:
mpd
It should automatically add all your music to your music directory, if not type:
mpc update
MPD will now take some time and import all your music but it is doing it rather fast.
Now we will create a desktop file to start MPD automatically on boot:
geany ~/.config/autostart/mpd.desktop
Add these lines:
[Desktop Entry] Encoding=UTF-8 Type=Application Name=Music Player Daemon Comment=Server for playing audio files Exec=mpd StartupNotify=false Terminal=false Hidden=false
Now MPD will start always as a daemon in the background on boot. It will also run as your user and not as root.
You can of course change some settings to your personal likings in the MPD configuration file.
users of Waldorf/Debian Wheezy/Debian Sid can change the auto_update function:
#auto_update "yes"
To prevent interference with other applications' volume settings, enable:
mixer_type "software"
You can set up replay gain with MPD, a great feature some music apps in Linux does not offer:
replaygain "track"
Gapless playback can be enabled with:
gapless_mp3_playback "yes"
These clients are available in Debian's repository:
ncmpc - An excellent curses based MPD client ncmpcpp - A concept fork of ncmpc written in C++ (popular pick!) ncmpy - A [Python + Curses]-based MPD client pms - A feature-rich and highly configurable ncurses based client with commands similar to vim Ario - A light and complete GTK2 client that runs on Linux and Windows gbemol - A GTK+ client with a nice library browser gmpc - Gnome Music Player Client - A fully featured, low on resources player Gimmix - A graphical MPD client written in C using GTK+2 sonata - A lightweight GTK+ client written in Python Glurp - A small GTK+ client written in C
Install the client of your choice, for example ncmpcpp
sudo apt-get install ncmpcpp
mpd itself does not feature an equalizer, however it is possible to add Alsaequal.
This is only for Testing/Unstable users. If you want to install alsaequal on Stable, you should compile it from source.
First we will install the required packages:
apt-get install libasound2-plugin-equal
Now we will create a .asoundrc file in your home directory but as your user not as root:
geany .asoundrc
That will open a blank text file, put this in:
ctl.equal {
type equal;
}
pcm.plugequal {
type equal;
# Modify the line below if you don't
# want to use sound card 0.
slave.pcm "plug:dmix";
}
# pcm.equal {
# Or if you want the equalizer to be your
# default soundcard uncomment the following
# line and comment the above line.
pcm.!default {
type plug;
slave.pcm plugequal;
}
Save and close the file.
To make use of the new sound configuration we will reload Alsa as root:
alsa force-reload
Now we can make use of the new EQ with:
alsamixer -D equal
The equalizer has to be added to the configuration file of mpd:
geany ~/.mpd/mpd.conf
Make following changes:
audio_output {
type "alsa"
name "My ALSA EQ"
auto_resample "no"
use_mmap "yes"
device "plug:plugequal"
format "44100:16:2" # optional
mixer_device "default" # optional
mixer_control "PCM" # optional
mixer_index "0" # optional
}
You have to add MPD to the audio group if not already done before. As root:
usermod -aG audio mpd
This command will prove if MPD is in that group:
cat /etc/group | grep audio
Now you can use MPD with alsaequal!
If you use ncmpcpp then you have the possibility for some fancy visualizations, at least on Testing/Unstable with version 0.5.6-2.
To be able to use them you have to go back to the MPD configuration file and add these lines to your audio output:
audio_output {
type "fifo"
name "My FIFO"
path "/tmp/mpd.fifo"
}
You can of course use your keyboard to control MPD without a GUI or because you prefer it this way. Some clients can provide that feature natively.
You can control MPD with some basic commands of MPC and making a short cut for your keyboard. Really simple:
mpc pause
will pause MPD and
mpc play
will play music.
You can use Conky with MPD too. Check the mega-thread on the forums.
For LastFM users there is mpdscribble. Install it with:
sudo apt-get install mpdscribble
Then we will begin to edit the /etc/mpdscribble.conf:
gksudo geany /etc/mpdscribble.conf
Only change this lines according to your username and password:
[last.fm] url = http://post.audioscrobbler.com/ username = yourusername password = yourpassword # The file where mpdscribble should store its Last.fm journal in case # you do not have a connection to the Last.fm server. journal = /var/cache/mpdscribble/lastfm.journal
You will see, you can even scrobble to LibreFM.
To activate the daemon:
gksudo geany /etc/default/mpdscribble
and change this line to look like:
# Whether to enable system wide daemon MPD_SYSTEMWIDE=1
Restart the thing (as root) with:
sudo service mpdscribble restart
and it will work, after a reboot it will also start automatically.