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.
Enter MPD
MPD (music player daemon) is an audio player that has a server-client architecture. It can easily manage large music libraries. To put “large” into perspective, we are talking about libraries with over 50k tracks or almost a terabyte of music. Even such huge libraries are no sweat for MPD. Add to that, the server-client architecture allows many applications to control music playback – even you can write an app to control the MPD server!
Installing MPD
The package is available in Arch Linux repository. You can install it via Pacman.
sudo pacman -S mpd
Configuration
Save it in ~/.config/mpd/ with name mpd.conf.
Uncomment some options at the beginning of this file. music_directory, db_file, pid_file and state_file. Set a location for all these as you like. At the very least I suggest changing the music_directory from “~/music” to “~/Music”. (notice the capital ‘M’). This is because the pre-created music folder starts with a capital ‘M’. It is not a restriction though. Often people store their music collection on an HDD, while the distro is installed on SSD. Having a state file isn’t necessary, however, enabling it will allow you to retain play queue when you restart MPD server.
At around line 97, uncomment restore_paused and set value to “yes”. This will ask MPD to start in “paused” state, otherwise music playback will start right on startup. However, you may want to have it disabled if you are installing on something like a Raspberry Pi, which will be used specially for music playback.
Save the file, and we are ready to move forward.
In this post, I have suggested edits in the config multiple times. Every time you edit the config file, you need to restart the MPD server for the changes to take effect.
Copying your Music Library
Copy your music folders/songs to ~/Music/. As simple as that! Remember we set the music_directory value to this folder? You can set that value to a different one if you don’t want to copy your library to a new place.
What do I do?
I will describe two set ups that I use.
On my laptop – it needs to be carried around; I can’t have my external drives always with me. So all my music is copied onto the internal HDD. This location is defined in the MPD config. The HDD is mounted automatically on boot since I have it added to my fstab.
Launch The Server!
Now, you are ready to launch the server! Open a terminal and run mpd. Exceptions about Tidal and wildmidi can be ignored. You can add this command to your startup script to have the server launch automatically when you log in. I have it in my i3wm config.
There is also a systemd service that you can use.
This will start the server automatically when you log in.
Important : MPD can be launched as root also, but don’t do that please!
Adding a Frontend – Cantata
What do you do after you have set up a server? You need a client software that can interact with your server. MPD, because its open source and has libraries in multiple languages, enjoys support for multiple frontends. A very popular one is ncmpcpp. It’s console based, and while I do like console applications, I also prefer managing music via a graphical application. So, I use Cantata, as it is feature rich and does a good job of interacting with MPD server. It also has an inbuilt tag editor and support for streaming from SoundCloud, Jamendo etc. It can also work without an MPD server by reading files directly off your storage.
According to the MPD webside canata and others are gone unmaintained: https://www.musicpd.org/clients/
Cantata first launch window
Next, you will be asked about server connection details. Use “localhost” for Host and “6600” for port. Alternatively, if mpd is running, then you can click on Discover button and choose your server. Enter a password if you configured it earlier. Set the music folder path to the folder you specified in mpd.conf. Now, hit Connect button. It should give success immediately, and you can now click Next at bottom of window.
Cantata server configuration window
You can enable/disable cover fetching as per your wish. Do note that enabling this feature will make Cantata connect to the internet and send basic track info online.
Cover download settings
Click Next, and now Cantata is ready for use.
You can use any other client – GUI or CLI – instead of Cantata.
Alternatives
Mpdevil is a simple music browser for the Music Player Daemon (MPD) which is focused on playing local music without the need of managing playlists. Instead of maintaining a client side database of your music library, mpdevil loads all tags and covers on demand. So you’ll never see any outdated information in the browser. Mpdevil strongly relies on tags.
Ymuse is an easy, functional, and snappy GTK front-end (client) for Music Player Daemon written in Go. It supports both light and dark desktop theme.
Get to know MPC
MPC is a simple command line client to mpd. It is used to issue commands to MPD and get info about the current track, queue etc. You can install it from your package manager or compile from source.
One command you should know right now is mpc update. This re-scans your music directory and creates a database of stored tracks. I bind it to Mod+Shift+m. Cantata also has option to update database, but I prefer using wm keybindings.
Some more commands that I have in my config:
Basic mpc commands
I have bound these commands to different wm keybindings and it lets me control playback right from the keyboard without leaving my active application. Note that its not necessary to use mpc. I mentioned it in this post because it allows easy control with terminal commands which can be used in your configs or wrapped in shell scripts.
Controlling MPD with your Android Phone
Now this is where the real fun starts. You can control MPD playback via your smartphone. This makes an easy set up, where you can have your MPD server on a Raspberry Pi and you control playback using your smartphone. And yeah, without using any spooky closed source proprietary applications.
Install one of the many MPD controlling apps available on the Play Store. I used MALP because it is open source and has a decent UI. On first launch, you will be on the profiles page. Tap the plus icon on top right and enter your server details. You can know your system IP address by running the ifconfig command. Note the IP address of the interface you are connected to (wifi, ethernet, etc).
You should now have your phone connected to your MPD server!
MALP running on Android devce
Utilizing HTTP Streams
This is another superpower of MPD, that you can stream music over a network (even the internet!).
Go into your mpd.conf and around line 270, uncomment httpd audio output.
You can increase the bitrate if you like. 256 is a sweet spot for http streaming of mp3 audio, but keep in mind that your FLAC/WAV music will be down-scaled before streaming. Also, I highly suggest changing the max_clients value to the number of simultaneous connections you would expect. In my configs, I set it to 1 because that’s what I need. If you are streaming music to multiple devices at once, set it to a higher value.
The host machine should be reachable via the other machine. If they are on same local network, all well and good. If not, you can still access the server outside your local network by port forwarding on your router.
You can also stream via icecast if you want. Here is the link to relevant Arch wiki entry. https://wiki.archlinux.org/title/Icecast
Music info/controls on your bar
Polybar has an MPD module that can display current track info and controls on your bar.
You can find the module code here: https://github.com/polybar/polybar/wiki/Module:-mpd
In case you want to suggest additions or changes to this entry, you can create a post under this forum thread : https://forum.endeavouros.com/t/beginner-s-guide-to-setting-up-and-using-mpd/16831