Use mpd and ncmpc++ like a pro


Looking for a simple, yet powerful music player that runs in the background? Are you bothered by all those heavy-weight graphical applications and just wish you could play music in the console? Then stop looking, because mpd and ncmpc++ will exceed all your expectations.

“Music Player Daemon (MPD) is a flexible, powerful server-side console application for playing music. Through plugins and libraries it can play a variety of sound files while being controlled by its network protocol. Ncmpc++ is a feature-rich ncurses client inspired by ncmpc.”

MPD makes an excellent background service that plays audio files locally, or streams music over http to everyone that wants to listen. It can be controlled by all sorts of clients, from full-fletched graphical to minimalistic console apps. Even a remote control like your mobile phone is possible. Ncmpc on the other hand is highly customizable ncurses console front-end that offers all the things you could wish from a client.

Inspired by K.Mandla and his series of articles “How to use <x> like a pro”, here’s a brief tour of mpd and ncmpc++, a glimpse of its features.

Table of Contents

1. Setting up mpd
2. Using mpd
3. Setting up ncmpc++
4. Using ncmpc++

Setting Up mpd

First, you will need to install mpd. Pretty much every linux distribution has it in their software repositories, hence the installation of the package shouldn’t be a problem. For Ubuntu it would be:

for Arch Linux:

For more information on installing mpd, you can always check out their extensive wiki. The few configuration changes that have to be made, are done in /etc/mpd.conf for system-wide use, or in ~/.mpdconf for individual users. I will only explain setting it up for each individual user as it has several advantages over a system wide install such as setting up a separate music library, own playlists and resume of songs for each user individually.

1. Copy the system wide configuration file /etc/mpd.conf to ~/.mpdconf (~ denotes the users home directory):

2. Before we edit the config file, we will create some files and directories we will be using later on:

3. Now edit ~/.mpdconf to reflect these settings:

As you will see in the config file, there are two entries for each setting: one system wide and one user based. You have to comment out the system wide ones with # and enable the user based by uncommenting them and filling in the correct values (like mine above). The names of the settings speak for themselves and additional documentation is often added in the configuration file itself. Be sure to replace /full/path/to/your/music/directory with the correct path to your music directory and yourusername with your actual username. You can change the port if you want to, but there’s generally no point in doing that. You can also restrict access to mpd (remember, you can control it from a remote device) by uncommenting the password entry and supplying a password. Typically, you don’t have to mess with the audio output settings, but if you have problems later on remember these settings: Uncommenting the alsa output is then your best bet (since it ships with basically every linux distribution by default as it is included in the kernel).

There also exists a configuration page on their wiki.

Using mpd

Now that you have mpd installed and configured, you can start using it. There really isn’t much to say about using mpd. All you have to do is running the command mpd as user and the program will create the music library database file. It will look into your music_directory, create an entry for each music file and put information about it in mpd.db:

The cool thing about having a command line music player daemon is that you don’t need a X server running to play music. Are you tired of your music stopping when you log on and off your system? No problem, mpd will keep running when you log on and off. When you start mpd it will also resume the last song that was playing if you abruptly stopped the mpd daemon.

If mpd gives you any trouble like not starting up, no sound or not creating a mpd.db file, check out mpd.log and mpd.error. It will give you a headstart in figuring out what’s wrong.

Setting up ncmpc++

Now we still need something to control mpd with. Ncmpcpp is almost an exact clone of ncmpc but it contains some new features ncmpc doesn’t have. It’s been also rewritten from scratch in C++ and more importantly, it’s actively being developped. As I told before, there exist other clients both command line and graphical as web based. Hell, you can even get a client that runs on your Iphone or Ipod Touch. But I can assure you, ncmpc++ pretty much does it all: playlists, crossfading, tag editing, fetching lyrics… You name it, it’s got it.

As far as I know only Arch Linux, Gentoo and FreeBSD have ncmpcpp in their software repositories. So you might have to get your hands dirty with compiling it yourself. But hey, if you already get so far reading this, it really shouldn’t be a problem. People seriously considering a console music player, probably have the skill to compile it as well. Detailed installation instructions can be found on the ncmpcpp site.

I’m not really going into the configuration of ncmpc++. The default configuration will certainly do. Only when you intend to use the tag editor, you will have to set the proper path to the mpd music directory in ~/.ncmpcpp/config (the path you also filled in the config file of mpd). The rest is a bunch of color and format settings. You can also configure the shortcut keys in ~/.ncmpcpp/keys. More on the shortcut keys later.

Using ncmpc++

You can launch ncmpc++ in the terminal with:

When you launch it, you are welcomed by the playlist window that shows the songs of the playlist you are currently listening to

Ncmpc++ Playlist

At the top, you see what menus are available and their corresponding key to access it (by default numbers from 1 to 7 and fn keys):
1:Help
2:Playlist
3:Browse
4:Search
5:Library
6:Playlist editor
7:Tag editor

The meaning of these menus are pretty obvious. A quick way to switch from the playlist to the browse menu and back is the tab key. The global keys to use in each menu are the arrow up and down to navigate and enter to select. To go to the parent directory you can use backspace. To start a selected song, press enter, s to stop a song and P to pause. > and < are used to go forward and backward one track. r is used to enable/disable repeat mode and z for random selection of the songs in the playlist. Deleting a song in your playlist can be done with d and clearing the whole playlist with c. You can increase and decrease the volume with + and -. If you want to quit ncmpc++, press q. As you can see, the shortcut keys somehow make sense, they mostly are the first character of the action you want to perform. Very easy to remember although it can be a bit overwhelming the first time.

Ncmpc++ Lyrics

When you stored a new music file in your music directory, you will have to update mpd’s database. I told you before that you can use this command. This functionality is triggered by the u key. So absolutely no need to quit ncmpcpp.

The previous short cuts were just the basic commands to get you started. This was only the beginning. You can for example cross-fade from one song to another with x. Fetching lyrics is l, looking up detailed information on the performing artist is I. The latter two perform a search on the internet. It’s possible it doesn’t find a match on the net, but that’s only the case with less known, most time local artist and songs. I tried it with some local artists from my country and it only missed one out of many. Another information key i gives you information about the music file itself such as file name and tags. You can go out of the lyrics, artist and file information screens by pressing the same button.

Ncmpc++ Artist Information

I’ll quickly look into searching your music database. If you have a playlist with a lot of songs or you have hundreds of artists, it’s very annoying to use the slow navigate arrow up and down key. You can instead do a quick forward and backward search with / and ?. If you want to perform a more complex search, you can always use the search menu (4 or F4) but I find that takes a lot of time and I don’t think a lot of people use it.

Ncmpc++ Search

Integrated with ncmpc++ is an advanced tag editor. It’s one of the few command line players for mpd that have this. With this you can edit whatever tag you want of a music file in your database. The usage speaks for itself. As I told before, to get this functionality to work, you will have to supply the path the music directory in ~/.ncmpcpp/config.

All of the shortcut keys are configurable in ~/.ncmpcpp/keys. If you are unhappy with a certain key, you can change each one of them in that file.

This is as far as I’m willing to go with covering ncmpcpp’s functionality. I believe I’ve summed up the most important things. Feel free to notify me of other things I have overlooked. All the functionality and how to access them should be listed in the help menu (1 or F1).