Setting up an off grid server, part 4. MPD.

MPD is an interesting take on music players. It runs as a service, playing music from play lists from local files. You’ll need a good client to talk to it (and there are many clients, for many devices) in order to setup and change the play lists. It can also play to either a local or a networked source, even streaming to the internet. It’s clearly in the extremely powerful, hard to set up category. Well, at least compared to other music players.

To set it up in Ubuntu, it’s actually pretty simple. First we install via the package manager.

sudo apt-get install mpd

And then we backup and edit the config file at /etc/mpd.conf. Here is mine.

#start file
music_directory        "/var/samba/root/Music/"
playlist_directory    "/var/lib/mpd/playlists"
db_file            "/var/lib/mpd/tag_cache"
log_file        "/var/log/mpd/mpd.log"
pid_file        "/var/run/mpd/pid"
state_file        "/var/lib/mpd/state"

user            "mpd"
bind_to_address        "any"
input {
 plugin "curl"
}

audio_output {
 type        "alsa"
 name        "My ALSA Device"
 device        "hw:0,0"    # optional
 format        "44100:16:2"    # optional
 mixer_device    "default"    # optional
 mixer_control    "PCM"        # optional
 mixer_index    "0"        # optional
}

filesystem_charset        "UTF-8"
id3v1_encoding            "UTF-8"

#end file /etc/mpd.conf

It may seem a little complicated, but the defaults are actually pretty sensible. I only changed the line “music_directory” to point to my personal repository and changed “bind_to_address” to “any” from its default of “localhost”. A reboot or an explicit service restart will cause MPD to start reading all your files and creating a database.

You can now hit your server from any other computer in your network with a MPD client, and the server will start playing music. For the moment, I’m using Ario simply because it was the first in the repository, but in the near future I’ll play with the others to find something I like. I’ll also be putting a client on my Wife’s android tablet if she’ll let me.

Now to some Panda specific issues. When I started playing files, the worse noise was going through the speakers. Loudly. Using AlsaMixer, I noticed (1) that every single control in the audio sub system was visible (more than 50 sliders and switches!) and (2), that it was very easy to set some of these values far beyond any sensible level. I found the level “DL1 Media” which defaulted to 100% was causing the issue, dropping it to about 25% left the audio clear and loud.

The second issue came after a restart. All the volume levels were back to their defaults, including the one mentioned above. It seems the audio driver in the panda is not properly saving it state on shutdown and restoring it on startup. I attempted to use the command “alsactl store”, restart and recall the settings with “alsa restore”, and that worked well. To automate this, I copied an alsa init script from here and stored it in /etc/init.d/alsa. I also had to comment out all the stat_* commands. Then I ran the following commands.

sudo chmod +x /etc/init.d/alsa
sudo update-rc.d alsa defaults

That last command creates all the proper links to allow the script to be ran as startup and shutdown with the proper arguments. Another restart proved it was all running properly. All volume levels remained at their edited values.

Advertisements

About Grant Wagner

General class ham: KC9SJQ https://grantwagner.wordpress.com
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s