Howto: Desktop musicpd (mpd) configuration

shepper

Aspiring Daemon

Reaction score: 320
Messages: 873

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 is started on a per/user basis rather than system wide. See Arch Linux mpd wiki for more details.
2. The daemon uses a unix socket rather than going through the TCP/IP stack.
3. The music directory has been moved from /var/mpdmusic to ~/Music for file location consistency with Common Desktops
4. 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 ~/.mpd/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, populate the previously created ~/.mpd with a playlists directory and db, log, pid, state, socket, sticker.sql files.

$ cd ~/.mpd && mkdir playlists
$ touch {db,log,pid,state,socket,sticker.sql}

To start the musicpd at each boot, place musicpd_enable="YES" in /etc/rc.conf
To start mpd, run the following command in your DE's autostart, ~/.xsession or ~/.xinitrc.
/usr/local/bin/musicpd ~/.mpd/musicpd.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.

Edits:
1. Added executable for music files and chain of directories.
2. Changed from system wide to per user basis.
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

Reaction score: 1,217
Messages: 2,252

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
shepper

shepper

Aspiring Daemon

Reaction score: 320
Messages: 873

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)
 
D

Deleted member 60479

Guest


Thank you for writing this terrific guide 🤝

ncmpcpp: Failed to resolve host name

Cantata works though. My mind's exploding. What possible wrong did I do?
 
D

Deleted member 60479

Guest


Thank you sir. It works. Although I had to bind to socket.
Code:
[mpd]
mpd_host = "~/.mpd/socket"
 

tuxador

Member

Reaction score: 40
Messages: 98

Hi, i don't know why but musicpd is not able to start after removing /usr/local/etc/musicpd.conf

/usr/local/etc/rc.d/musicpd: WARNING : /usr/local/etc/musicpd.conf is not readable.
/usr/local/etc/rc.d/musicpd: WARNING : failed precmd routine for musicpd.
 
OP
shepper

shepper

Aspiring Daemon

Reaction score: 320
Messages: 873

Hi, i don't know why but musicpd is not able to start after removing /usr/local/etc/musicpd.conf
/usr/local/etc/rc.d/musicpd is called by musicpd_enable in /etc/rc.conf. It starts musicpd systemwide. This guide starts musicpd on a per user basis.
From the 1st post:
To start mpd, run the following command in your Desktop Environments's autostart, ~/.xsession or ~/.xinitrc.
/usr/local/bin/musicpd ~/.mpd/musicpd.conf
.
 
Top