Howto: Desktop musicpd (mpd) configuration

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                 "/home/XXX/Music"
playlist_directory              "/home/XXX/.mpd/playlists"
db_file                                  "/home/XXX/.mpd/db"
log_file                                 "/home/XXX/.mpd/log"
pid_file                                 "/home/XXX/.mpd/pid"
state_file                             "/home/XXX/.mpd/state"
sticker_file       "/home/XXX/.mpd/sticker.sql"
user                                     "XXX"
group              "XXX"
bind_to_address              "/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, ~/.config/ncmpc/config, 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 log out and back in or start musicpd with
$ /usr/local/bin/musicpd ~/.mpd/musicpd.conf. 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.
3. Corrected musicpd start command in the prior paragraph.
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:
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.
 
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)
 
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?
 
Thank you sir. It works. Although I had to bind to socket.
Code:
[mpd]
mpd_host = "~/.mpd/socket"
 
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.
 
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
.
 
Hi, I have musicpd and a bluetooth connection with my speaker. I also have M.A.L.P on my phone. I can't figure out why volume control is not functioning from phone. Do you have any suggestion?

Code:
audio_output {
        type            "oss"
        name            "Default OSS Device"
        device          "/dev/dsp"      # optional
        mixer_type      "hardware"      # optional
        mixer_device    "/dev/mixer"    # optional
        mixer_control   "vol"           # optional
}

PS: on clementine it worked.
 
For people using windowmaker:-

I just set up mpd and this nice little dockapp this evening for listening to music...


I followed the howto to set up mpd, had to make a few changes but got it to work (the main gotcha was having to change '/usr/home' to '/home' in musicpd.conf). And to run the dockapp itself you need:-

$ MPD_HOST=/home/XXX/.mpd/socket /usr/local/bin/wmpdart

- where 'XXX' is your user name. Then of course you can put the dockapp in the wmaker dock and control mpd with it.
 
For people using windowmaker:-

I just set up mpd and this nice little dockapp this evening for listening to music...


I followed the howto to set up mpd, had to make a few changes but got it to work (the main gotcha was having to change '/usr/home' to '/home' in musicpd.conf). And to run the dockapp itself you need:-

$ MPD_HOST=/home/XXX/.mpd/socket /usr/local/bin/wmpdart

- where 'XXX' is your user name. Then of course you can put the dockapp in the wmaker dock and control mpd with it.
Corrected /home path - thanks for pointing it out.
 
I set this up again with 14.4R yesterday and got it all working. I'm not quite sure why you have said set 'x' permission on the audio files in the howto change history, I don't think that is needed, at least it works on my system without that. Yes it is needed on subdirectories of ~/Music because the software needs to be able to cd to them, but why on the music files themselves?

Everything works great. The only problem I found was that mpd ignores volume change requests, sent to it for example by using the left and right arrow keys in ncmpc (it also ignores the '+' and '-' keys). I noticed there are some bug reports of similar problems on github. I wondered if anyone who has used mpd with freebsd has found a fix for the volume control commands not working? I have used the audio/musicpd package, I haven't compiled mpd myself. The workaround is to control the oss mixer directly to vary the volume.

Below is a little screenshot from my windowmaker doc showing the 'wmix' (for mixer control) and 'wmpdart' dockapps, playing music over mpd as configured according to this howto. I can configure the playlist using ncmpc, and then close the ncmpc window and control music playback from the dockapps alone, which is nice.

The two dockapps used to control audio are shown below, namely wmix at the top to control mixer volume and wmpdart below to control music playback. Wmpdart displays a scrolling banner giving the name of the currently playing track, and allows me to start and stop playback, and to switch to the next or previous track in the playlist. Wmpdart sends mpd command requests to mpd itself across the socket in ~/.mpd. You can even get it to display album covers in the dockapp, but I haven't bothered using that feature.

1774076478551.png


At some point I want to try adding some code to wmpdart to open ncmpc in an xterm by right clicking on it... :)
 
Back
Top