Music from the Command Line

In addition to programming I also love music. If I’m not listening to music I’m probably not working. While I love Pandora, my slightly off-mainstream musical tastes means that I start getting repeats pretty soon. I carry my personal library on my iPod but I don’t like listening on my iPod all day. Also, if the office is empty and my computer has speakers I like to take the headphones off and turn up the music. Last week I realized that my work machine had a 500 GB hard drive in addition to the SSD so I decided to copy my personal library on to it.

I know that there are a number of good music players for Linux but I personally wanted a very lightweight setup and didn’t need any “management” features (I have everything neatly organized into Artist and Album folders anyways). So I decided to use a little gem called MPD – the Music Player Daemon.

MPD is a daemon – it runs in the background and plays your music. It doesn’t provide an interface itself but you can connect to it using a number of clients. I love MPD becuase it’s very UNIX-y and just gets out of your way. You tell it where your music is and point it to a number of files it needs for operation (logs, a database and some state information). You then tell MPD which user to run as and a port on localhost to listen on. Here’s my config file.


music_directory                 "~/Music"
playlist_directory              "~/mpd"
db_file                         "~/mpd/mpd.db"
log_file                        "~/mpd/mpd.log"
pid_file                        "~/mpd/mpd.pid"
state_file                      "~/mpd/mpdstate"

user                            "username"
bind_to_address                 "127.0.0.1"
port                            "6600"

. As you can tell from the screenshots, it’s a lightweight but fully functional client.

This kind of setup probably isn’t cup of tea but I don’t want to convince you that it’s better than whatever current setup you have. For me this is amazing for a number of reasons. Firstly it’s quickly configurable and it stays out of my way after that. Second it’s very lightweight. Ncmcpp comes up in a second, I can quickly go through my library and add a few hours of music and set it to play. Then I can close it and not give it a second thought as I do my work. Since it’s so quick to come up, I can keep the client closed and open it if I do need to do something (like skip a track or see what’s playing). Since I have a terminal (or five) open at any time, it’s a quick process the few times I do have to do it.

Reason three is the client-daemon model. I think there are graphical clients that give you more standard functionality, but since I don’t need any of that, it isn’t forced upon me either. There is however an even lighter client called mpc (that is part of the standard MPD install) which lets you execute some actions like play, pause and skip without even opening a full client. Thus interaction is even faster.

In conclusion, if you’re looking for a simple, efficient music player that will play your music and stay out of your way then MPD is worth a try. If you’re not a command-line afficionado you might like one of the graphical clients. I’ve used Sonata myself in the past and liked it.

Advertisements

Published by

Shrutarshi Basu

Programmer, writer and engineer, currently working out of Cornell University in Ithaca, New York.

One thought on “Music from the Command Line”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s