Quarantine Project: Back to MPD

After using various audio players, console and GUI, I’ve recently made my way back to a trusty old friend – MPD. Wikipedia briefly describes it as so:

Music Player Daemon (MPD) is a free and open music player server. It plays audio files, organizes playlists and maintains a music database. In order to interact with it, a client program is needed. The MPD distribution includes mpc, a simple command line client.

MPD by itself isn’t all that useful as it only provides the server part of the server-client model that it is. You need a client to interact with it and there are a handful to choose from.

Installation

Since I’m a Debian user these instructions will also reflect Ubuntu and its far too many forks and derivatives. If you use an RPM-based distro or something else, you’ll figure this part out. You got it.

My client of choice for MPD is ncmpcpp so we’ll throw that in for good measure:

$ sudo apt install mpd ncmpcpp

Configuration

In Debian and Ubuntu-based distros that use APT, there’s a tendency to automatically start services but for our uses we’re going to disregard that and run MPD on a per-user basis. First we’ll disable MPD via systemd:

$ sudo systemctl stop mpd
$ sudo systemctl disable mpd
$ sudo systemctl stop mpd.socket
$ sudo systemctl disable mpd.socket

MPD has a whole bunch of options which I’m not even going to attempt to cover here so we’ll just use my configuration as an example. You’ll want to create the path for it along with the playlists directory with mkdir -p ~/.config/mpd/playlists.

Here’s my stupidly simple configuration which you’ll want to save as ~/.config/mpd/mpd.conf:

# Simple MPD config
music_directory "~/Music"

db_file            "~/.config/mpd/database"
log_file           "~/.config/mpd/log"
playlist_directory "~/.config/mpd/playlists"
pid_file           "~/.config/mpd/pid"
state_file         "~/.config/mpd/state"
sticker_file       "~/.config/mpd/sticker.sql"

bind_to_address "localhost"
port            "6600"

replaygain       "album"
replaygain_limit "yes"

# PulseAudio sink
audio_output {
  type "pulse"
  name "PulseAudio"
}

# FIFO
audio_output {
  type   "fifo"
  name   "my_fifo"
  path   "/tmp/mpd.fifo"
  format "44100:16:2"
}

Once you have that saved you should be good to execute mpd which if all goes well will create a database of your music and should be running on port 6600.

Next up is controlling MPD using the client we installed by running ncmpcpp. Much like MPD configuration options I won’t cover that here but there’s a handy ncmpcpp cheat sheet to familiarize yourself with it.

The End – Again?

Two posts in two days? Yeah, I don’t know what’s going on either.

As a caveat I should add that there’s plenty of documentation out there on getting MPD installed and configured and you can even do a deep dive into the many configuration options that ncmpcpp has. If I continue doing these posts it’s not so much to further redundant guides since I’m a terrible documenter, it’s more that I’m happy to provide steps based on my own experience that has worked entirely well for me and possibly me alone.

YMMV is an understatement here.

Welp, cheers.