14 February 2017

mpd, ncmpcdd, perl, CPAN and song ratings on OSX

Hi there, been a while - so, buzzword bingo anyone ;-).

Having grown tired of the weight and cost of a GUI I am returning to my lighter-weight roots as much as possible. I can't quite reproduce the fantastic experience of i3 on the mac but using terminal based apps is a good first step.

So, after experimenting with the excellent cmus I was sold on the convenience of terminal based music players (did I mention how fast these things are?!). However, cmus, whilst excellent had a few things that didn't quite gel with me:

  • slightly inconsistent keyboard mappings
  • no way to navigate via tags
  • no way to rate songs and therefore noway to build dynamic play lists

The other great contender is mpd which is a music player daemon/server with a whole shedload of clients. The most popular one seems to be ncmpcpp.

Installing it was a breeze, follow this although ignore the instruction to create mpd.db otherwise mpd will complain of a corrupted DB.

After installing mpd and ncmpcpp it is time to use them. By far the best reference I have found for ncmpcpp is this cheat sheet.

So, great, except ncmpcpp doesn't rate songs. The main contender for that seems to be a Perl module ("app?"): https://metacpan.org/release/Audio-MPD. I confess, despite over 20 years of professional software engineering I have managed to not touch Perl ;-). So, what do you do with a Perl thingy?

Turns out:

  • CPAN is the maven of the Perl world
  • cpan install <module> installs that library so Perl 'apps' can access it
  • a Perl 'app' is really just a shell script that uses the perl interpreter

With this knowledge, getting hold of mpd-dump-ratings and mpd-rate is as simple as:

  1. configure cpan on your mac if you haven't already by executing cpan
  2. clone the github repo locally
  3. cpan install AUDIO:MPD (analog of mvn install) installs the MPD library locally
    1. run it again as it failed for me the first time :-)
  4. in the bin directory of the github repo you cloned you can find mpd-dump-ratings,mpd-dynamic and mpd-rate

So, have a read through the documentation and link those 3 scripts to your local ~/bin directory (or whatever directory you have in your $PATH for just such a thing).

I am almost certainly doing something wrong and non-idiomatic and upgrades are, as ever, welcome.

That's all for now folks - see you in another few months ;-).

Tags: tools osx perl cli music