death of a rubygem

I’ve spent many hours over the last 6 months or so working on a ruby gem called hearken. I listen to a lot of music and have found every graphical music player very poor at handling large music collections and irritatingly inefficient to use via keyboard (iTunes could easily be the worst piece of software ever).

Hearken is a command line music player/jukebox.  It consists of a couple of executables: one rips the tags out of your music collection and stores them in an index file.  The main executable is a command line console application that allows you to search, queue and play music.  It also has last.fm integration if you’re into that sort of thing.

The latest version does most of what I originally had in mind. I used it exclusively to listen to music for the last few months.  Future enhancements would have involved remote access – a simple web interface and a web api for clients to use (iOS, android, etc.).

With some combination of disappointment and relief, I came across Music Player Daemon.  It does everything I ever wanted hearken to do. It has many clients for different platforms available (MPDroid for android, MPoD/MPaD for iOS, Theremin for mac).  I think it might actually even work on windows.

Here’s how easy it was to install (on mac os x lion):

brew install mpd mpc mpdscribble ncmpc

mpd is the daemon process. mpc is a simple command line client. mpdscribble is a last.fm audio scrobbling client.  ncmpc is a more powerful ncurses cli client.

Here’s how you get the daemon up and running:

mkdir -p ~/.mpd/playlists
echo 'port                    "6600"
music_directory         "/Users/Shared/Music"
playlist_directory      "~/.mpd/playlists"
db_file                 "~/.mpd/mpd.db"
log_file                "~/.mpd/mpd.log"

audio_output {
  type            "osx"
  name            "My Mac Device"
  mixer_type      "software"
}

audio_output {
  type      "httpd"
  name     "My HTTP Stream"
  encoder  "vorbis"
  port	   "8000"
  bitrate  "128"
  format    "44100:16:1"
}' > ~/.mpd/config
mpd ~/.mpd/config

Now mpd is running.  It will detect that the mpd.db does not yet exist and so will start recursing though your music collection, extracting tags and populating its database.

If you specify no audio_output sections, mpd will find a default audio device but you won’t be able to remotely control volume. The second audio section above enables streaming music over http to any device on your home network. Remote clients are able to toggle these audio_outputs on and off.

To watch its progress:

tail -f ~/.mpd/mpd.log

Note that ~/.mpd/mpd.db is a fairly simple text based format in case you happen to have some other reason to quickly access tag information from your music collection.

Now, to get scrobbling happening:

mkdir ~/.mpdscribble
echo '[mpdscribble]
  log = /Users/USERNAME/.mpdscribble/mpdscribble.log
  verbose = 2
  sleep = 1
  musicdir = /Users/Shared/Music

  [last.fm]
  url = http://post.audioscrobbler.com/
  username = LASTFM_USER_NAME
  password = LASTFM_PASSWORD
' > ~/.mpdscribble/mpdscribble.conf
mpdscribble

Now, play some music

mpc search artist sigur | mpc add
mpc play

Install MPod on your iPhone, MPad on your iPad, MPDroid on your android and control the player, volume using your home wireless network. mpc and ncmpc also can be used to control a remote mpd with the -h parameter from a console.

I learned a lot by writing hearken but am now planning to let it slowly sink back into the ocean. By cutting my losses and completely abandoning any similarly futile software projects, I can focus on other more important things.

A similar fate may befall shh and cardigan.