mon, 26-nov-2007, 15:20

Simone Dinnerstein, Goldberg Variations album cover

simone dinnerstein, goldberg variations (telarc)

At work, on my Linux box, I listen to music with the Music Player Daemon (MPD) and command-line mpc client. I have managed to build both MPD and mpc on my MacBook Pro, but I haven’t figured out how to configure MPD to play through AirTunes to my stereo. There are commercial solutions, but I don’t want to have to pay money just to listen to my music on my stereo wirelessly. DVD Jon figured out how the AirTunes encryption works, and even wrote a program that you can use at the end of a pipe to stream music to the AirPort. But I haven’t figured out how to glue the MPD audio output together with JustePort.exe so I can play music this way on my Mac.

So what’s wrong with just using iTunes? Well, it’s a snazzy program, but I can’t script it the way I want to, I can’t easily control it from the command line, and it is limited in what file types it can handle (like OGG for example: you can get a plugin that will play OGG, but you can’t burn CDs using those OGG files).

Here’s an example of why I like MPD. The Telarc label recently joined eMusic and I was pleased to discover that Simone Dinnerstein’s recent, well-reviewed interpretation of Bach’s Goldberg Variations appeared on the site. I downloaded it, and also ripped the Bach Edition version (by Pieter-Jan Belder on harpsichord) from the set of Bach CDs I’m working my way through. After listening to them all the way through several times, album by album, I decided I wanted to listen to them with the two albums interlaced so I’d hear the Belder version of a variation followed directly by the Dinnerstein version. There are 32 of them. Imagine how many mouse movements and clicks it would be to get iTunes to do this.

Here’s how I did it with MPD and mpc. It took about 30 seconds, mostly trying to figure out how to get bash to do math.

First, here’s what the playlist looked like initially. The Belder harpsichord version was first, occupying tracks 1-32 in the playlist. Dinnerstein’s 1903 Hamburg Steinway concert grand version occupies tracks 33-64. So I needed to move track 33 to position 2, track 34 to position 4 (because track 2 was now in position 3), 35 to 6. See the pattern? [Dinnerstein track] moved to [([Dinnerstein track] - 32) * 2]

$ mpc playlist
>1) Pieter-Jan Belder - Bach: Goldberg Variations - Aria
 2) Pieter-Jan Belder - Bach: Goldberg Variations - Variatio 1
 3) Pieter-Jan Belder - Bach: Goldberg Variations - Variatio 2
 4) Pieter-Jan Belder - Bach: Goldberg Variations - Variatio 3, canone all'unisono
...
 33) Simone Dinnerstein - Bach: Goldberg Variations: Aria
 34) Simone Dinnerstein - Bach: Goldberg Variations: Variation 1
 35) Simone Dinnerstein - Bach: Goldberg Variations: Variation 2
 36) Simone Dinnerstein - Bach: Goldberg Variations: Variation 3 (Canone all'Unisono)

And here’s the command to reorder the playlist. The extra dollar signs and parentheses are just bash’s way of escaping parentheses so they’ll be interpreted as an arithmetic expression.

$ for i in `seq 33 64`; do mpc move $i $(($(($i-32))*2)); done

And the playlist afterwards:

$ mpc playlist
>1) Pieter-Jan Belder - Bach: Goldberg Variations - Aria
 2) Simone Dinnerstein - Bach: Goldberg Variations: Aria
 3) Pieter-Jan Belder - Bach: Goldberg Variations - Variatio 1
 4) Simone Dinnerstein - Bach: Goldberg Variations: Variation 1
 5) Pieter-Jan Belder - Bach: Goldberg Variations - Variatio 2
 6) Simone Dinnerstein - Bach: Goldberg Variations: Variation 2
 7) Pieter-Jan Belder - Bach: Goldberg Variations - Variatio 3, canone all'unisono
 8) Simone Dinnerstein - Bach: Goldberg Variations: Variation 3 (Canone all'Unisono)
...

And then:

$ mpc play
tags: bash  iTunes  mpd  music  programming  shell 
Meta Photolog Archives