Howto: Desktop musicpd (mpd) configuration

shepper

Aspiring Daemon

Thanks: 245
Messages: 735

#1
MPD audio/musicpd is one of the lightest, most responsive methods to access mp3, ogg files and internet streams. Installation entails 2 components; the daemon and one of a number of front ends. On an older i386, playback of locally stored mp3's or internet music streams uses less than 2% of the CPU.

This configuration differs from the default musicpd.conf in the following ways:
1. The daemon uses a unix socket rather than going through the TCP/IP stack.
2. The music directory has been moved from /var/mpdmusic to ~/Music for file location consistency with Common Desktops
3. The volume control has been moved from "PCM" to "vol". In the standard OSS setup, "vol" is the master volume control as used by system tray volume apps. The volume setting in your mpd front end will match the system tray app.

To start, install audio/musicpd and one or more front ends. I use audio/ncmpc as a front end
.
You can delete the default /usr/local/etc/musicpd.conf as it is already backed up by /usr/local/etc/musicpd.conf.sample.
Paste the following into /usr/local/etc/musicpd.conf and replace "XXX" with your user name.
Code:
music_directory                 "/usr/home/XXX/Music"
playlist_directory              "/usr/home/XXX/.mpd/playlists"
db_file                                  "/usr/home/XXX/.mpd/db"
log_file                                 "/usr/home/XXX/.mpd/log"
pid_file                                 "/usr/home/XXX/.mpd/pid"
state_file                             "/usr/home/XXX/.mpd/state"
sticker_file       "/usr/home/XXX/.mpd/sticker.sql"
user                                     "XXX"
group              "XXX"
bind_to_address              "/usr/home/XXX/.mpd/socket"

# Input #######################################################################
#

input {
        plugin "curl"
#       proxy "proxy.isp.com:8080"
#       proxy_user "user"
#       proxy_password "password"
}

#

# Audio Output ################################################################
#
# MPD supports various audio output types, as well as playing through multiple
# audio outputs at the same time, through multiple audio_output settings
# blocks. Setting this block is optional, though the server will only attempt
# autodetection for one sound card.
#
# An example of an OSS output:
#
audio_output {
type "oss"
name "My OSS Device"
device "/dev/dsp" # optional
mixer_type      "hardware" # optional
mixer_device "/dev/mixer" # optional
mixer_control "vol" # optional
}
#
As user, create ~/.mpd and populate it with a playlists directory and db, log, pid, state, socket, sticker.sql files.
$ mkdir ~/.mpd
$ cd ~/.mpd && mkdir playlists
$ touch {db,log,pid,state,socket,sticker.sql}

Create the mpd socket in the users environment on each login with the following line in ~/.profile
Code:
MPD_HOST=${HOME}/.mpd/socket;      export MPD_HOST
To start the musicpd at each boot, place musicpd_enable="YES" in /etc/rc.conf

Lastly, your front end will need to be configured to use the unix socket as the host. In audio/ncmpc, start ncmpc with
ncmpc --host=~/.mpd/socket
or place
Code:
host = /usr/home/XXX/.mpd/socket
in the ncmpc configuration file.
My ncmpc configuration file for xterm-color (The "color background = none" entry uses the default terminal background color, in my case a dark grey):
Code:
host = /usr/home/XXX/.mpd/socket
enable-mouse = no
welcome-screen-list = yes
list-format = "%file%"
enable-colors = yes
color background = none
color title = cyan
color line = blue
color list = white
color status-song = white
Place your music files in ~/Music/ and verify that the individual music files and the chain of directories are executable.

Either reboot or start musicpd with
# /usr/local/etc/rc.d/musicpd start. If you do not see any of your music files in the front end, run mpd update. In audio/ncmpc <CTL-U> will update the playlist directory.

Edit: Added executable for music files and chain of directories.

Credit to David Coppa, mpd port maintainer for OpenBSD for sharing his mpd.conf and uzsolt for his mailing list post on the syntax for OSS mixer_control.
 
Last edited:

Rigoletto

Daemon
Developer

Thanks: 731
Messages: 1,617

#2
I don't remember what is the default for metadata_to_use but I would add albumartist in the if it is not yet. I remember of having to add it at some point.
 
OP
OP
shepper

shepper

Aspiring Daemon

Thanks: 245
Messages: 735

#3
My goal was to provide a basic, lightweight configuration to start with. Further customization is possible.

Mpd is the only free software music player I know which doesn't hearable pause between two songs when the artists didn't intended it.
uii, There is an musicpd.conf option to fade between songs that can easily be added to the above configuration. The syntax is in /usr/local/etc/music.conf.sample. ncmpc(1) also provides a fade option.
I don't remember what is the default for metadata_to_use but I would add albumartist in the if it is not yet. I remember of having to add it at some point.
lebarondemerde ncmpc has display options under Song Format: ncmpc(1)
 
Top