UP  |  HOME

MPD (Music Player Daemon)

Table of Contents

MPD allows access from any address and uses a password for security.

The config file is well explained.

Shared pulseaudio daemon, separate sink

Edit /etc/pulse/default.ca to enable a unix socket for sharing the pulse daemon, and set a default sink for other applications.

Listing 1: /etc/pulse/default.pa (excerpt)
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.1.0/24
set-default-sink alsa_output.usb-SCEA_Inc._Logitech_USB_Headset-00.analog-stereo

Grab the full names of your sinks:

pactl list sinks|grep Name
Name: alsa_output.usb-SCEA_Inc._Logitech_USB_Headset-00.analog-stereo
Name: alsa_output.pci-0000_0e_00.3.analog-stereo
Name: alsa_output.pci-0000_0c_00.1.hdmi-stereo

See the pulse output section of mpd.conf for setting the sink.

Restart pulseaudio and mpd:

pulseaudio --kill
pulseaudio --start
systemctl restart mpd
Listing 2: /etc/mpd.conf
# MPD config for  HTTP stream and Pulse out to specific sound card
# some other fixes

# Client got locked out when I added the whole library, maybe fix
max_output_buffer_size "32768"

# filesystem info
music_directory         "/path/to/music"
follow_outside_symlinks "no"
follow_inside_symlinks  "no"
filesystem_charset      "UTF-8"

# other files
playlist_directory      "/var/lib/mpd/playlists"
db_file                 "/var/lib/mpd/tag_cache"
log_file                "/var/log/mpd/mpd.log"
pid_file                "/run/mpd/pid"
state_file              "/var/lib/mpd/state"
sticker_file            "/var/lib/mpd/sticker.sql"

# config stuff
user                    "mpd"
bind_to_address         "any"
restore_paused          "no"
auto_update             "no"
replaygain              "album"
volume_normalization    "yes"

# not using right now
zeroconf_enabled        "no"
zeroconf_name           "zeroconf name"

# set up password and their access
password <password>
default_permissions     ""

input {
    plugin "curl"
}

# simple stream for remote listening
audio_output {
    type         "httpd"
    name         "My HTTP Stream"
    encoder      "vorbis"        # optional, vorbis or lame
    port         "8000"
    quality      "5.0"           # do not define if bitrate is defined
    max_clients  "5"             # optional 0=no limit
}

# main pulse output, server and sink can be dropped for single card
# pulse is configured to use a unix socket
# get sink names from "pactl list sinks|grep Name"
audio_output {
    type        "pulse"
    name        "MPD Pulse Out"
    server      "127.0.0.1"
    sink        "alsa_output.usb-0d8c_USB_Sound_Device-00.analog-stereo"
}

# Fix some bad mp3 playback with default decoder
decoder {
    plugin  "mad"
    enabled "no"
}

decoder {
    plugin "wildmidi"
    enabled "no"
}

MPD Sima

MPD Sima adds tracks to the play queue using similar artists from last.fm.

Listing 3: /etc/mpd-sima.cfg
# For exhaustive options lits see manual: man 5 mpd_sima.cfg
# or /usr/share/doc/mpd-sima/examples/

[MPD]
host = localhost
port = 6600
password = <password>

[log]
logfile = /var/log/mpd-sima/mpd-sima.log
# Possible values: debug, info, warning, error
# PAY ATTENTION: *DEBUG LEVEL MIGHT PRINT OUT YOUR PASSWORD*
verbosity = info

# These settings deal with MPD_sima core behaviour.
[sima]
internal = Crop, Lastfm, Random
#contrib =
## HISTORY_DURATION (in hours)
history_duration = 16

[lastfm]
## QUEUE_MODE
# Possible values: track, top, album
queue_mode = track
track_to_add = 3
depth = 8
cache = True
priority = 35

[crop]
# Keep all played tracks
consume=-1

[random]
flavour=sensible
priority= 30

# vim: syntax=cfg fileencoding=utf-8

mpdscribble

mpdscribble scrobbles song plays to last.fm (or other scrobbling services) to record your music habits.

Listing 4: /etc/mpdscribble.conf
## mpdscribble - an audioscrobbler for the Music Player Daemon.
## http://mpd.wikia.com/wiki/Client:mpdscribble

# HTTP proxy URL.
#proxy = http://the.proxy.server:3128

# The location of the pid file.  mpdscribble saves its process id there.
#pidfile = /var/run/mpdscribble.pid

# Change to this system user after daemonization.
#daemon_user = mpdscribble

# The location of the mpdscribble log file.  The special value
# "syslog" makes mpdscribble use the local syslog daemon.  On most
# systems, log messages will appear in /var/log/daemon.log then.
# "-" means log to stderr (the current terminal).
log = syslog

# How verbose mpdscribble's logging should be.  Default is 1.
verbose = 1

# How often should mpdscribble save the journal file? [seconds]
#journal_interval = 600

# The host running MPD, possibly protected by a password
# ([PASSWORD@]HOSTNAME).  Defaults to $MPD_HOST or localhost.
host = <password>@localhost

# The port that the MPD listens on and mpdscribble should try to
# connect to.  Defaults to $MPD_PORT or 6600.
#port = 6600

[last.fm]
url = http://post.audioscrobbler.com/
username = <user>
password = <password>
# The file where mpdscribble should store its Last.fm journal in case
# you do not have a connection to the Last.fm server.
journal = /var/cache/mpdscribble/lastfm.journal

#[libre.fm]
#url = http://turtle.libre.fm/
#username = my_username
#password = my_password
#journal = /var/cache/mpdscribble/librefm.journal

#[jamendo]
#url = http://postaudioscrobbler.jamendo.com/
#username = my_username
#password = my_password
#journal = /var/cache/mpdscribble/jamendo.journal

#[file]
#file = /var/log/mpdscribble/log