MPD
The Music Player Daemon is a music server that can be located either remotely or locally. MPD has support for MP3, Ogg, FLAC, AAC, Mod, and wav files.
Contents |
About MPD
MPD is used for primarily for either of two basic functions: as a remote daemon on a network, or a local daemon. Because of its minimal need for resources both servers and desktop users use MPD. MPD does require some setting up to have it run correctly.
Install MPD
Add the basic sound formats to the USE flags:
echo "media-sound/mpd aac flac mp3 ogg vorbis" >> /etc/portage/package.use
and install MPD
emerge -av mpd
Configuring MPD for a Local Daemon
Configurations for MPD differ depending on if you want to use MPD as a local daemon or network daemon. MPD is originally designed to run as a server and its default settings reflect that. MPD can be configured through either ~/.mpdconf per user, or globally in /etc/mpd.conf.
Setting Permissions per User
A base root setup needs to be completed first.
In /etc/mpd.conf add a valid user to be able to run the init-script.
sudo vim /etc/mpd.conf
Allow regular user access to MPD's files.
sudo chown -R user /var/lib/mpd /var/run/mpd /var/log/mpd
As regular user, create each of MPD's log files to have regular user permissions.
touch /var/log/mpd/mpd.log touch /var/log/mpd/mpd.error.log
Copy /etc/mpd.conf to $HOME/.mpdconf.
cp /etc/mpd.conf ~/.mpdconf
Create the local configuration directories:
mkdir ~/.mpd mkdir ~/.mpd/playlists
Now edit the preferences file $HOME/.mpdconf and specify the MPD file locations:
music_directory "~/Audio-Directory" playlist_directory "~/.mpd/playlists" db_file "~/.mpd/database" log_file "/var/log/mpd/mpd.log" error_file "/var/log/mpd/mpd.error.log"
Also you will need:
- The pid setting to be active to shutdown the MPD daemon.
- MPD will not run without a valid username.
- Most users will want to allow the Alsa Mixer.
- Commenting out replaygain? Changing to "album" is usually a good idea since not all CD's are recorded at the same volume level. A replaygain preamp of -3 is a good place to start.
Create the Music Database
Setup roots database (required but not used.)
sudo -u root mpd --create-db
As regular user, create a database.
mpd --create-db
(Alternately) Single-User Only
The configuration file /etc/mpd.conf can be used if you are configuring a server or are the only person on the computer who plans use MPD.
The user will need to have read and write access to the files listed in /etc/mpd.conf
Verify these exist:
/var/lib/mpd/music code>/var/lib/mpd/playlists code>
MPD requires it's configuration files to belong to the audio group and to the owner listed in the configuration file
chown user:audio /var/lib/mpd chmod gu+s /var/lib/mpd chown user:audio /var/log/mpd/ /var/log/mpd/* /var/run/mpd/ /var/run/mpd/*
Link MPD to your Audio Directory
cd /var/lib/mpd/music ln -s /home/user/audio-collection .
Create the Music Database
As regular user, create a database.
mpd --create-db
Configuring MPD as a Remote Daemon
A MPD server will typically create a user "mpd" and have proper settings to begin distributing sounds over a network.
Due to the client-server model, you will need to make sure connections to the port MPD listens to is possible. Edit /etc/init.d/mpd such as the depend section looks like
| File: /etc/init.d/mpd |
[...]
depend() {
need alsasound localmount net.lo
use netmount nfsmount
}
[...]
|
| Code: Set perms |
cd /var/lib/mpd /usr/bin/mpd --create-db chown mpd:audio -R . chmod ug+rwX ./* -R chmod o-rwx . -R |
This will provide a /var/lib/mpd/database file readable-writable to anyone in the audio group.
Start MPD
/etc/init.d/mpd start
Add the daemon to the run-level:
rc-update add mpd default
Picking a Client
Command Line Clients
CLI options include media-sound/mpc and media-sound/ncmpc (You will want to enable local useflags for the second, like, e.g. search-screen). MPC is better used bound to keys (esp. if you own a multimedia keyboard).
| Shell: Using MPC |
emerge -av mpc mpc ls music_subfolder/some_band | mpc add mpc play |
Ncmpc is a curses client for the Music Player Daemon.
| Shell: Using ncmpc |
emerge -av ncmpc ncmpc -c |
Also clients are listed at the
Troubleshooting MPD
The pid
For mpd-0.1.3 and prior. Setting a pid file isn't automatic. Have a pid is necessary to restart or shutdown Alsa or mpd itself. This is an over-sight of MPD as it does not create a new pid on initializing but requires one to shutdown. Also shutdown will delete any manually created pid. The only solution I've found is to add this information to the MPD boot script.
touch /var/run/mpd/mpd.pid chown user:audio /var/run/mpd/mpd.pid
MPC connection refused
If you want to use MPC with MPD, and get following error when starting mpc:
MPD_HOST and/or MPD_PORT environment variables are not set error: problem getting a response from "localhost" on port 6600 : Connection refused
First make sure that MPD is running (/etc/init.d/mpd status). Still not working, the solution may be adding some variables to your /etc/make.conf:
MPD_HOST="localhost" MPD_PORT="6600"
Or, you could try commenting out the following in mpd.conf:
| File: /etc/mpd.conf |
bind_to_address "localhost" |
Resources
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.
