Music Player Daemon

If you are storing your music file on your home server’s hard drive, so why don’t you play it from here ?

That’s just what I did, especially with the SPDIF output on the server’s motherboard connected to my sound system, that would have been a waste not to use it!

But it’s a server, it has no screen, no keyboard…

You can play your music using mpg321 from an ssh connection, you can even use screen, that would work. But there is a nice program that’s even better for that case: Music Player Deamon aka MPD

It’s a Music Player controlled by a network protocol. So you need to install it on your server, you also need to install some clients. I suggest to install some command line ones line mpc and ncmpc.

Configure the directory containing your music collection, and that’s basically it, you can listen to your music…
Ok mpc is not really a lot better that mpg321…

You have a server, so you can host a website client! There are many listed on the client page on http://mpd.wikia.com.

Personally I already have an apache server with PHP, so hosting a python script that would behave as yet another web server is not what I consider a “light” client.

I picked relaxx.

The development is still active, but it’s pretty usable already, some might not like it’s green theme (like my brother), I don’t really care but changing css shouldn’t be that hard 😉

The other important thing is your music collection, you have to organize it in folders as client will show your folder structure to select music. Also the tags should be nice as they are used for displaying song title, or for searching by criteria.

I started that task earlier while using Amarok, the tag really needed to be nice as the music was organized according to tags…

So I did prepare a set of rules for directory layout and file naming, but moving all the music to that structure is a long an painful task. Until I tried Music Brainz tagger software: picard.

Not only Picard can fill up the tag for you by fetching some information on Music Brainz’s servers but it can also move your file to your collection directory with the organisation of (almost) your choice.

The “almost” is because for the lonely file that doesn’t fit any album, you’ll have to chose where to place it by yourself…
But for the rest it’s pretty powerful: it has a scripting macro language that allows you to manipulate the tags information in order to build your filename!

I wanted my collection to include no special character to avoid issues when copying to FAT, or accessing the same hard drive from several OS (like mounting with ext2ifs on windows, or going through samba without the right charset conversion options…) and I was surprised that picard allowed this !

Here is an extract of my configuration file (it can be found in ~/.config/MusicBrainz/Picard.conf)

windows_compatible_filenames=true
ascii_filenames=true
rename_files=true
move_files=true
file_naming_format="$replace($rreplace($if2(%albumartist%,%artist%)/$left(%date%,4) - %album%/$num(%tracknumber%,2) - %title%,[.?!'\\,],),&,n)"

The options windows_compatible_filenames=true and ascii_filenames=true are already doing most of the job, then the file_naming_format that is using the scripting feature replace the remaining chars : dot(.) question mark(?) bang(!) quote(‘) and comma (,) with nothing and the ampersand(&) with a lower case N(n).

For more information about the scripting functions have a look here, also this page is useful as it lists the tag names as used in the scripts.

Last treatment to the mp3 in the collection: some equalization and replay gain with mp3gain.
So all the music will sound equally loud (actually equally low, but as low as DVDs are, so your 5.1 sound system volume will not change that often!).