MPD on Mac OS X

My story really starts with Trackbox, an experiment of a perl script daemon I wrote long ago that worked like a headless jukebox daemon and allowed a client program to connect to it to provide a user interface to allow the user to browse the collection of music, manage playlists, play, pause, change volume, and all the other things you expect from a media player. It was pretty hacky, but it did the job. When Shank got MPD, the Music Player Daemon, working properly in raw C, though, I retired Trackbox. MPD is very similar to Trackbox: a super lightweight daemon that sits in the background, performing the duties of of music player. If I don’t need to interact with it, I don’t even need to have a client running — like when my linux tower boots and the init script starts it up. MPD resumes playing where it left off before I even launch X. I’ve obviously been a long time fan of even the idea of MPD.

I’ve been using a Mac increasingly over recent years. It started with a 15″ MacBook Pro for work, and eventually I got a 13″ one for personal use. My current and second Mac is a 13″ 2011 MacBook Air, and I’ve been frankly thrilled with it. Macs are great, but but I think a lot of folks endure the frustration of hunting for a great music player that simply doesn’t seem to exist.

Currawong started this excellent thread on head-fi which gives a really great overview and discussion on the most visible Mac music player options. I’ve tried most of them, but never really found one to my liking. Each was either buggy, lacking features, stupid expensive, or didn’t maintain a library, making practical use limited. I have gone back to iTunes every once in a while, and I’ve always been disappointed with crashing or general bloaty slowness. I finally went as far as to uninstall it from my system entirely, reclaiming hundreds of megabytes. (After removing the, I simply used the Preferences screen of “Software Update” to disable future update notifications.) I must say, I don’t miss it, not one little bit.

I finally decided to give MPD a go on the Mac. After using it for perhaps about a month now, I can happily say it is absolutely my new favorite. At home, I mount my server’s RAID array, and at work, I mount my off-site backup, a 3Tb external drive at my desk, so I always have my full collection of mostly lossless music readily at my disposal. I’ve even found a nice way to start mpd with different config files so I can aim it at the server or the local collection, depending on what I need. Being a global hotkey junkie, I’ve mapped restarting mpd with each config to a different key.

MPD is only as nice to use as the client you’re using. Theremin is nice native Mac one, but seems fairly unmaintained at this point. It scrobbles and has album art, but its main drawback for me is that it doesn’t allow browsing the collection by directory structure like most clients. I would recommend giving this one a try; it may fit the bill. There are countless others to choose from, though. I managed to get the excellent, GTK-based Sonata client to run under OS X with the help of MacPorts, but it is a bit kludgey. Client175 is a very nice, web-based one.

I’ve actually found myself liking the terminal-based ncmpcpp client best. It is jam-packed with features, remains blazingly quick, and even has the ability to add a random album, artist, or track to the playlist! I can understand why many folks might not like using a console client, but it works really well for me. Bind it to pop up with a global hotkey, and you have a slick, quick-launching client that you don’t even need running most of the time!

The other client I use is mpc, the command-line interface client. I barely ever actually use it on the command line, though, but through global hotkeys to toggle (play/pause) and play next track. I’ve also written a wrapper for mpc that allows me to play (or append to the playlist) random tracks on random albums. The most unique feature of my tool is the ability to specify “top-level” directories by a pre-designated “short code” and add random tracks or albums only from within one top-level dir at a time. The main directories of my collection are genres, so I can throw on some random ambient music or random drum ‘n bass. For example, with my Alfred extension, I do my ⌘+space to open him up, and type, “rt db” — immediately 10 random drum ‘n bass tracks are added, and the first one plays.

Honestly, this has revolutionized how I listen to my music. I often don’t even have the patience to drill down my folder structure or otherwise hunt for something to listen to. Now I can tell alfred “rt ch” and have random chill out beats. If I want to hear the entire album for one of the songs, ⌘⌥5 will play it.

I use and adore Alfred for many things including setting up these global hotkeys, and I feel it is worth plenty more than what Andrew is asking for it. But if you want something that is free, I recommend BetterTouchTool. Here is the key configuration I use on my Air:

  • ⌘⌥1: play/pause toggle
  • ⌘⌥2: next track
  • ⌘⌥3: play 10 random tracks from entire collection (hold shift to append)
  • ⌘⌥4: play 1 random album from entire collection (hold shift to append)
  • ⌘⌥5: play the album the currently playing song belongs to (hold shift to append)
  • or all the above, holding Control as well causes the command to be directed at my server, which drives the living room speakers/headphone system
  • Control+⌥+n: launch ncmpcpp under iTerm2

(Note: I use Control+⌥+letter to launch / switch focus to my most often used apps. This makes me very efficient and I love it.)

MPD does the trick for me. It is slim, efficient, and invisible. I can do 90% of everything I need with a simple global hotkey, and Growl gives me feedback. When I actually do want to browse around or manage the playlist, ncmpcpp or other client lets me do that. There are some folks who look for an “audiophile” player, but the fact is that if the program can decode the file and feed it to the audio device in a “bit perfect” manner, every app should sound the same. I think there are apps that are broken and don’t do this quite right, and I also think there are people who get fall victim to the placebo effect. I really see no reason to worry about the sound quality of MPD — I trust it.

I’ve uploaded my mpct.php script to GitHub in case anyone is interested in it. If you use it, I would love to hear about your experience. If you have any questions about any of this, I would really love to hear from you in the comments!

Installing MPD

Installing MPD on OS X is really easy according to their instructions. Simply install homebrew with

/usr/bin/ruby -e "$(curl -fsSL"

then use

brew install mpd

I really like this brew software manager! I can even install packages they don’t provide with something like

brew create //

Tuesday, December 27th, 2011 Audio, Computers, Reviews, Software

11 Comments to MPD on Mac OS X

  1. Do you have any problems with MPD and headphones on Macbook Air? My MPD-0.16.7 hangs on OS X Lion when I plug/unplug headphones and I need to kill -9 it.

  2. Max on March 20th, 2012
  3. Yeah.. I also have a similar issue when I connect or disconnect a USB DAC. My solution is to bind a global hotkey to essentially “killall -9 mpd; mpd” … This makes it really quite simple to reinit MPD when I need to. It’s not ideal, but definitely something I can live with.

    Btw, if you need a hint, check out BetterTouchTool for binding a little bash script to a global hot key. (I use Alfred.)

  4. thread on March 20th, 2012
  5. Filed a bug: //

  6. Max on March 20th, 2012
  7. Nice! Thanks for that :)

  8. thread on March 20th, 2012
  9. I’m trying to get mpd/ncmpcpp to play my iTunes Music folder in place and getting stuck with playing from .m3u playlists. The playlists load and display correctly but pressing Enter causes only the briefest flash of the “Now playing” mode line at screen bottom. Can’t find any log files or other error messages. Any ideas?

  10. Phil Hudson on May 9th, 2012
  11. Hi Phil; Thanks for stopping by!

    I bet it’s because the playlist file is malformed or not what MPD is expecting. Maybe the file locations are different etc. To be honest, I *never* use playlists, and always favor loading particular tunes or albums directly.

    If I was serious about solving such a problem, I might create a similar playlist in MPD and actually compare it with the iTunes-made playlist in a text editor. The difference would almost certainly become clear at that point. Who knows, maybe the answer is another bit of script-fu to translate between one and the other. ;)

  12. thread on May 9th, 2012
  13. Thanks for creating such an amazing guide. I had been a foobar2k user in Windows for so many years now and using Mac was dreading when it comes to organizing and playing the music on Mac. Thanks to these awesome trio (mpd + mpc + ncmpcpp) setup I can finally enjoy playing and discovering music on Mac!

    One question though. I had downloaded the mpct at the GitHub but I couldn’t find out what should I do to install it. Is it possible to create a guide on how to use the script? And how to integrate it nicely with Alfred?

  14. Gary on May 14th, 2012
  15. I am soooo glad you commented, Gary. I’ve sort of been meaning to do a screencast and guide on this, but haven’t actually taken the next steps. I also have some polish/documentation on mpct that I haven’t pushed up yet.

  16. thread on May 14th, 2012
  17. Thanks for the effort of doing it. I really hope to see that documentation coming.

  18. Gary on May 15th, 2012
  19. Hi! Thanks for the guide!
    I hacve trouble configuring an external usb DAC with MPD. Any suggestion? I did not find any document.

  20. Patroclo on May 16th, 2012
  21. Open your sound pref pane and select the DAC to be your default output device. Because of a “bug” in MPD, you’ll need to restart MPD for it to attach to the new default device. I’ve scripted a global hotkey to “killall mpd && /usr/local/bin/mpd /some/mpd.conf” so it’s easy for me to do, but ideally the bug that Max filed (linked in his comment above) will eventually get resolved.

    Good luck, Patroclo !

  22. thread on May 16th, 2012

Leave a comment

Latest Tweets


My History