# Howto: Desktop musicpd (mpd)  configuration



## shepper (Jan 2, 2016)

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.

```
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

```
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):

```
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.


----------



## rigoletto@ (Sep 30, 2018)

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.


----------



## shepper (Sep 30, 2018)

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



uii said:


> 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.


lebarondemerde said:


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


----------



## rigoletto@ (Sep 30, 2018)

Hm. I use audio/ncmpcpp but at that time I used to use audio/cantata and I couldn't get `albumartist` information without that addition. However I didn't test without `albumartist` while using audio/ncmpcpp.


----------



## Deleted member 60479 (Nov 18, 2020)

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?


----------



## twllnbrck (Nov 18, 2020)

jackson said:


> ncmpcpp: Failed to resolve host name


Did you add something like

```
[mpd]
mpd_music_dir = "~/Music"
mpd_host = "localhost"
```
to your ~/.ncmpcpp/config?


----------



## Deleted member 60479 (Nov 19, 2020)

Thank you sir. It works. Although I had to bind to socket.

```
[mpd]
mpd_host = "~/.mpd/socket"
```


----------



## delphinoob (Feb 14, 2021)

ah i wish qmmp (a winamp clone) could connect to mpd 
too bad


----------



## tuxador (Mar 20, 2021)

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.`


----------



## shepper (Mar 22, 2021)

tuxador said:


> 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


.


----------



## zsolt (Oct 11, 2021)

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?


```
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.


----------



## zsolt (Dec 31, 2021)

In the meantime I figure it out. Must be: mixer_type "software" in order for the volume buttons to work in malp.


----------

