To scrobble your songs to [http://www.last.fm Last.fm] when using MPD, there are several possibilities.

−

====mpdscribble====

+

MPD does not provide a tool to preserve the file structure of your audio files. Check out [http://beets.radbox.org/ beets] or [http://musicbrainz.org/doc/MusicBrainz_Picard/ picard].

−

mpdscribble is a daemon, available in the "community" repository (if you prefer, the "git" version is available in the [https://aur.archlinux.org/packages.php?ID=22274 AUR]). This is arguably the best alternative, because it's the semi-official MPD scrobbler and uses the new "idle" feature in MPD for more accurate scrobbling. Also, you do not need root access to configure it, because it doesn't need any changes to {{ic|/etc}} at all. Visit [http://mpd.wikia.com/wiki/Client:Mpdscribble the official website] for more information.

To scrobble your songs to [http://www.last.fm Last.fm] or [http://libre.fm Libre.fm] when using MPD, there are several possibilities.

+

+

==== mpdas ====

+

+

mpdas is an AudioScrobbler client for MPD written in C++. It uses {{Pkg|curl}} and {{Pkg|libmpd}}. mpdas supports the latest AudioScrobbler protocol (2.0) and will also cache unscrobbled plays in ~/.mpdascache if there's no network connectivity.

+

+

{{AUR|mpdas}} is available in the [[AUR]]. Visit [http://50hz.ws/mpdas/ the official website] for more information.

+

+

Configuration of mpdas is very simple, below is an example:

+

+

* Edit the file {{ic|/etc/mpdasrc}}:

+

{{hc|/etc/mpdasrc|2=

+

username = LASTFM USER

+

password = PASSWORD IN MD5

+

debug = 1

+

#runas is an optional feature. It change the user mpdas runs as

+

runas = USERNAME

+

#host is an optional feature to set the current mpd host

+

host = HOST

+

#mpdpassword is an optional feature to set the current mpd password

+

mpdpassword = MPDPASS

+

#port is an optional feature to set the current mpd port

+

port = MPDPORT

+

}}

+

+

A very basic example of {{ic|/etc/mpdasrc}} is also available as {{ic|/etc/mpdasrc}}.

+

+

To get your password in md5 hash, just run:

+

echo -n 'PASSWORD' | md5sum | cut -f 1 -d " "

+

+

* Add {{ic|mpdas}} to the file in which you start {{ic|mpd}} as well (e.g. {{ic|~/.xinitrc}}):

{{AUR|mpdcron-git}} is available in the [[AUR]]. Visit [http://alip.github.io/mpdcron/ the official website] for more information.

+

+

==== mpdscribble ====

+

+

{{AUR|mpdscribble}} is a daemon available in the [[AUR]] (if you prefer, {{AUR|mpdscribble-git}} is also available). This is arguably the best alternative, because it is the semi-official MPD scrobbler and uses the new "idle" feature in MPD for more accurate scrobbling. Also, you do not need root access to configure it, because it does not need any changes to {{ic|/etc}} at all. Visit [http://mpd.wikia.com/wiki/Client:Mpdscribble the official website] for more information.

After you have installed mpdscribble, do the following (not as root):

After you have installed mpdscribble, do the following (not as root):

Line 18:

Line 64:

* Create the file {{ic|~/.mpdscribble/mpdscribble.conf}} and add the following:

* Create the file {{ic|~/.mpdscribble/mpdscribble.conf}} and add the following:

Sonata has built-in support for scrobbling, although that requires the program to run the whole time. Additionally, Sonata doesn't cache the songs if they cannot be forwarded to Last.fm at the time of playing, meaning they will not be added to the statistics.

−

====lastfmsubmitd====

+

Since systemd is default on new installations, starting mpdscribble with .xinitrc is outdated. mpdscribble should be started per user with systemd. See [[Mpd#Start_MPD_per_user_with_systemd]] and [[Systemd/User]].

−

The daemon lastfmsubmitd is a daemon which may be installed from the "community" repository as well. To install it, first edit {{ic|/etc/lastfmsubmitd.conf}} to reflect your requirements and add both {{ic|lastfmsubmitd}} and {{ic|lastmp}} to the {{ic|DAEMONS}} array in {{ic|/etc/rc.conf}}.

−

====Last.fm playback====

+

Install {{Pkg|mpdscribble}}.

−

=====Native Last.fm playback=====

+

−

Since version 0.16 mpd has a very well working method to [http://mpd.wikia.com/wiki/Last.fm_Radio play back last.fm streams].

With the current version {{Pkg|mpdscribble 0.22-5}}, adding the sections mentiond above to {{ic|~/.mpdscribble/mpdscribble.conf}} is not necessary. Just add your username and password.

−

This feature is present in mpd after version 0.16.2. When this feature is enabled, the mpd process will always start in the "paused" state, even if a song was playing when mpd was stopped. Add the line below to your {{ic|mpd.conf}} file to enable this feature.

−

restore_paused "yes"

−

The following sections detail various methods to simulate the same feature for older versions of mpd.

+

Then, edit a new file ~/.config/systemd/user/mpdscribble.service

+

{{hc|~/.config/systemd/user/mpdscribble.service|

+

[Unit]

+

Description &#61; MPD Scribbler

−

====Installing mpd from the AUR====

+

[Service]

−

This is the best method currently available, but is only currently (as of April 2011) enabled in the git version. Install [https://aur.archlinux.org/packages.php?ID=19676 mpd-git] from the [[AUR]] and add {{ic|restore_paused "yes"}} to your {{ic|mpd.conf}} file.

+

ExecStart &#61; /usr/bin/mpdscribble -D

+

Restart &#61; always

−

If you have issues with connecting your client to [https://aur.archlinux.org/packages.php?ID=19676 mpd-git], see [[Music Player Daemon/Troubleshooting#Other issues when attempting to connect to mpd with a client]].

+

[Install]

+

WantedBy &#61; default.target

+

}}

−

====Method 1====

+

Now, enable and start mpdscribble.service as per user

−

If you do not want MPD to always play on your system start, but yet you want to preserve the other state information, add the following lines to your {{ic|/etc/rc.d/mpd}} file:

+

$ systemctl --user enable mpdscribble

−

=====Method 1.1=====

+

$ systemctl --user start mpdscribble

−

Simpler, working method (disables playing on startup of mpd daemon):

−

start)

−

...

−

mpc -q pause #add this line only

−

add_daemon mpd

−

stat_done

−

To prevent updates from destroying these modifications, add this file to the {{ic|NoUpgrade}} variable in {{ic|/etc/pacman.conf}}:

+

==== Sonata and Ario ====

−

NoUpgrade = etc/rc.d/mpd

−

====Method 2====

+

Sonata has built-in support for scrobbling, although that requires the program to run the whole time. Additionally, Sonata does not cache the songs if they cannot be forwarded to Last.fm at the time of playing, meaning they will not be added to the statistics.

−

Another simpler method, would be to add mpd to your {{ic|[[rc.conf]]}} daemons array and add {{ic|mpc stop}} or {{ic|mpc pause}} to {{ic|/etc/rc.local.shutdown}} and to {{ic|/etc/rc.local}}. (Remember you must have mpc installed to use this method).

−

Adding only the order in {{ic|/etc/rc.local}} cannot assure that mpd will play absolutely nothing, since there may be a delay before the stop command is executed.

+

==== lastfmsubmitd ====

−

On the other hand, if you only add the order to {{ic|/etc/rc.local.shutdown}}, that will assure that mpd won't play at all, as long as you properly shutdown your system.

−

Even though they are redundant, adding it to {{ic|/etc/rc.local}} would serve as a safety for those, presumably, rare occasions when you do not shutdown the system properly.

−

====Method 3====

+

The daemon lastfmsubmitd is a daemon which may be installed from the official repositories as well. To install it, first edit {{ic|/etc/lastfmsubmitd.conf}} to reflect your requirements and activate both {{ic|lastfmsubmitd}} and {{ic|lastmp}} systemd services.

−

The general idea is to ask mpd to pause music when the user logs out, so that mpd will stick to the "pause" state after a reboot. Sending such command can be achieved using [http://www.archlinux.org/packages/extra/x86_64/mpc/ mpc], the command line interface to MPD.

−

GDM users can then add {{ic|/usr/bin/mpc pause}} to {{ic|/etc/gdm/PostSession/Default}} (be sure to add it before {{ic|exit 0}}):

+

=== Never play on start ===

−

Non-GDM users can use their own login manager's method to launch the line at logout.

+

This feature is present in mpd after version 0.16.2. When this feature is enabled, the mpd process will always start in the "paused" state, even if a song was playing when mpd was stopped. Add the line below to your {{ic|mpd.conf}} file to enable this feature.

''Why these formats?'' Because they are standard CDA, because ALSA on its own allows more than one program "to sound" only with dmix — whose resampling algorithm is inferior — and because dmix by default resamples anything lower to 48 KHz (or whatever higher format is playing at the time). Also, some get clicking sounds if at least {{ic|mpd.conf}} is not changed this way.

''Why these formats?'' Because they are standard CDA, because ALSA on its own allows more than one program "to sound" only with dmix — whose resampling algorithm is inferior — and because dmix by default resamples anything lower to 48 KHz (or whatever higher format is playing at the time). Also, some get clicking sounds if at least {{ic|mpd.conf}} is not changed this way.

−

''What's the downside?'' These settings cause ''everything'' (if necessary) to be resampled to this format, such as material from DVD or TV which usually is at 48 KHz. But there is no known way to have ALSA dynamically change the format, and particularly if you listen to far more CDs than anything else the occasional 48 → 44.1 isn't too great a loss.

+

''What is the downside?'' These settings cause ''everything'' (if necessary) to be resampled to this format, such as material from DVD or TV which usually is at 48 KHz. But there is no known way to have ALSA dynamically change the format, and particularly if you listen to far more CDs than anything else the occasional 48 → 44.1 is not too great a loss.

The following assumes that there are not already other settings which conflict resp. overwrite it. This applies especially to the current user's potential {{ic|~/.asoundrc}} — which MPD as its own user ignores, therefore the following should go to {{ic|/etc/asound.conf}}:

The following assumes that there are not already other settings which conflict resp. overwrite it. This applies especially to the current user's potential {{ic|~/.asoundrc}} — which MPD as its own user ignores, therefore the following should go to {{ic|/etc/asound.conf}}:

Line 135:

Line 167:

}}

}}

−

{{Note|MPD gives the mp3 format a special treatment at decoding: It's always put out as 24 bit. (The conversion as forced by the ''format'' line only comes after that.)}}

+

{{Note|MPD gives the mp3 format a special treatment at decoding: it is always put out as 24 bit. (The conversion as forced by the ''format'' line only comes after that.)}}

If one wants to leave the bit depth decision to ALSA resp. MPD, comment out resp. omit the ''dmix.format'' line and change the one for mpd with ''format'' to "44100:*:2".

If one wants to leave the bit depth decision to ALSA resp. MPD, comment out resp. omit the ''dmix.format'' line and change the one for mpd with ''format'' to "44100:*:2".

Line 142:

Line 174:

=== Control MPD with lirc ===

=== Control MPD with lirc ===

−

There are already some clients designed for communications between lircd and MPD, however, as far as the practical use, they aren't very useful since their functions are limited.

−

It's recommended to use mpc with irexec. mpc is a command line player which only sends the command to MPD and exits immediately, which is perfect for irexec, the command runner included in lirc. What irexec does is that it runs a specified command once received a remote control button.

+

There are already some clients designed for communications between lircd and MPD, however, as far as the practical use, they are not very useful since their functions are limited.

+

+

It is recommended to use mpc with irexec. mpc is a command line player which only sends the command to MPD and exits immediately, which is perfect for irexec, the command runner included in lirc. What irexec does is that it runs a specified command once received a remote control button.

First of all, please setup your remotes as referred to the '''[[Lirc]]''' article.

First of all, please setup your remotes as referred to the '''[[Lirc]]''' article.

When run as its own user as per the wiki instructions, mpd will be unable to send sound to another user's pulseaudio server. Rather than setting up pulseaudio as a system-wide daemon, a practice strongly discouraged by upstream, you can instead configure mpd to use pulseaudio's tcp module to send sound to localhost:

−

First, uncomment the tcp module in {{ic|/etc/pulse/default.pa}} or {{ic|~/.pulse/default.pa}} and set 127.0.0.1 as an allowed IP address; the home directory takes precedence:

+

When run as its own user as per the wiki instructions, mpd will be unable to send sound to another user's pulseaudio server. Rather than setting up pulseaudio as a system-wide daemon, a practice strongly discouraged by upstream, you can instead configure mpd to use pulseaudio's tcp module to send sound to localhost:

+

+

First, uncomment the tcp module in {{ic|/etc/pulse/default.pa}} or {{ic|$XDG_CONFIG_HOME/default.pa}} (typically {{ic|~/.config/pulse/default.pa}}) and set 127.0.0.1 as an allowed IP address; the home directory takes precedence:

### Network access (may be configured with paprefs, so leave this commented

### Network access (may be configured with paprefs, so leave this commented

Line 261:

Line 302:

#load-module module-zeroconf-publish

#load-module module-zeroconf-publish

−

Additional IP ranges in cidr notation may be added using {{ic|;}} as the separator. Once this is complete, restart pulseaudio:

+

Additional IP ranges in cidr notation may be added using {{ic|;}} as the separator. Once this is complete, restart pulseaudio:

$ pulseaudio --kill

$ pulseaudio --kill

$ pulseaudio --start -or- start-pulseaudio-x11/kde

$ pulseaudio --start -or- start-pulseaudio-x11/kde

Line 272:

Line 313:

}

}

−

Once this is added, restart mpd:

+

Once this is added, restart mpd.

−

# rc.d restart mpd -or- systemctl restart mpd.service

Enable the output in mpd; you should now have a working local mpd, usable by all users whose pulseaudio servers allow sound from 127.0.0.1.

Enable the output in mpd; you should now have a working local mpd, usable by all users whose pulseaudio servers allow sound from 127.0.0.1.

Line 279:

Line 319:

==== Remote ====

==== Remote ====

−

As with any PulseAudio-enabled program, mpd can send sound over the network. The complete PulseAudio system is not required on the server running mpd; {{Pkg|libpulse}} is the only requirement to act as a source and is already a dependency of mpd.

+

As with any PulseAudio-enabled program, mpd can send sound over the network. The complete PulseAudio system is not required on the server running mpd; {{Pkg|libpulse}} is the only requirement to act as a source and is already a dependency of mpd.

−

In order to send audio from mpd to another computer follow the directions above, editing {{ic|/etc/mpd.conf}} on the server running mpd using the IP address of the target computer and {{ic|/etc/pulse/default.pa}} or {{ic|~/.pulse/default.pa}} on the target computer using the IP address of the server.

+

In order to send audio from mpd to another computer follow the directions above, editing {{ic|/etc/mpd.conf}} on the server running mpd using the IP address of the target computer and {{ic|/etc/pulse/default.pa}} or {{ic|$XDG_CONFIG_HOME/default.pa}} (typically {{ic|~/.config/pulse/default.pa}}) on the target computer using the IP address of the server.

Once this is done, the server's mpd source should show up on the target computer while playing or paused as a normal source able to be rerouted and controlled as usual; there will be no visible source on the target while mpd is stopped.

Once this is done, the server's mpd source should show up on the target computer while playing or paused as a normal source able to be rerouted and controlled as usual; there will be no visible source on the target while mpd is stopped.

Line 287:

Line 327:

=== Cue Files ===

=== Cue Files ===

−

To make cue file support actually work, you have to work around a nasty libcue bug. Libcue copied some files directly from libcdio, making it conflict with it. Steps to do to get proper cue support:

+

No additional steps are needed for cue support in mpd since 0.17. MPD has its own integrated parser which works with both external and embedded cuesheets.

+

For example, the command {{ic|mpc load albumx/x.cue}} loads the file {{ic|''music_directory''/albumx/x.cue}} as playlist; or in the case of an CUESHEET tag, {{ic|mpc load albumx/x.flac}}.

−

* remove {{Ic|libcdio}} temporary ({{Ic|pacman -Rdd libcdio}})

+

=== HTTP Streaming ===

−

* install {{Pkg|libcue}}

−

* install mpd with [[ABS]] or from [[AUR]].

−

* install {{Ic|libcdio}} again

−

Version 0.17 will fix this issue, implementing its very own cue parser, which will then also allow parsing cuesheets, that are embedded into the files tags (CUESHEET tag). This will work for most, if not all relevant music files.

−

−

=== HTTP Streaming ===

Since version 0.15 there is a built-in HTTP streaming daemon/server that comes with MPD. To activate this server simply set it as output device in mpd.conf:

Since version 0.15 there is a built-in HTTP streaming daemon/server that comes with MPD. To activate this server simply set it as output device in mpd.conf:

Last.fm/Libre.fm scrobbling

To scrobble your songs to Last.fm or Libre.fm when using MPD, there are several possibilities.

mpdas

mpdas is an AudioScrobbler client for MPD written in C++. It uses curl and libmpd. mpdas supports the latest AudioScrobbler protocol (2.0) and will also cache unscrobbled plays in ~/.mpdascache if there's no network connectivity.

username = LASTFM USER
password = PASSWORD IN MD5
debug = 1
#runas is an optional feature. It change the user mpdas runs as
runas = USERNAME
#host is an optional feature to set the current mpd host
host = HOST
#mpdpassword is an optional feature to set the current mpd password
mpdpassword = MPDPASS
#port is an optional feature to set the current mpd port
port = MPDPORT

A very basic example of /etc/mpdasrc is also available as /etc/mpdasrc.

To get your password in md5 hash, just run:

echo -n 'PASSWORD' | md5sum | cut -f 1 -d " "

Add mpdas to the file in which you start mpd as well (e.g. ~/.xinitrc):

pidof mpdas >& /dev/null
if [ $? -ne 0 ]; then
mpdas &
fi

mpdcron

mpdscribble

mpdscribbleAUR is a daemon available in the AUR (if you prefer, mpdscribble-gitAUR is also available). This is arguably the best alternative, because it is the semi-official MPD scrobbler and uses the new "idle" feature in MPD for more accurate scrobbling. Also, you do not need root access to configure it, because it does not need any changes to /etc at all. Visit the official website for more information.

After you have installed mpdscribble, do the following (not as root):

$ mkdir ~/.mpdscribble

Create the file ~/.mpdscribble/mpdscribble.conf and add the following:

Sonata and Ario

Sonata has built-in support for scrobbling, although that requires the program to run the whole time. Additionally, Sonata does not cache the songs if they cannot be forwarded to Last.fm at the time of playing, meaning they will not be added to the statistics.

lastfmsubmitd

The daemon lastfmsubmitd is a daemon which may be installed from the official repositories as well. To install it, first edit /etc/lastfmsubmitd.conf to reflect your requirements and activate both lastfmsubmitd and lastmp systemd services.

Never play on start

This feature is present in mpd after version 0.16.2. When this feature is enabled, the mpd process will always start in the "paused" state, even if a song was playing when mpd was stopped. Add the line below to your mpd.conf file to enable this feature.

Why these formats? Because they are standard CDA, because ALSA on its own allows more than one program "to sound" only with dmix — whose resampling algorithm is inferior — and because dmix by default resamples anything lower to 48 KHz (or whatever higher format is playing at the time). Also, some get clicking sounds if at least mpd.conf is not changed this way.

What is the downside? These settings cause everything (if necessary) to be resampled to this format, such as material from DVD or TV which usually is at 48 KHz. But there is no known way to have ALSA dynamically change the format, and particularly if you listen to far more CDs than anything else the occasional 48 → 44.1 is not too great a loss.

The following assumes that there are not already other settings which conflict resp. overwrite it. This applies especially to the current user's potential ~/.asoundrc — which MPD as its own user ignores, therefore the following should go to /etc/asound.conf:

audio_output {
type "alsa" # Use the ALSA output plugin.
name "HDA Intel" # Can be called anything or nothing tmk, but must be present.
options "dev=dmixer"
device "plug:dmix" # Both lines cause MPD to output to dmix.
format "44100:16:2" # the actual format
auto_resample "no" # This bypasses ALSA's own algorithms, which generally are inferior. See below how to choose a different one.
use_mmap "yes" # Minor speed improvement, should work with all modern cards.
}
samplerate_converter "0" # MPD's best, most CPU intensive algorithm. See 'man mpd.conf' for others — for anything other than the poorest "internal", libsamplerate must be installed.

Note: MPD gives the mp3 format a special treatment at decoding: it is always put out as 24 bit. (The conversion as forced by the format line only comes after that.)

If one wants to leave the bit depth decision to ALSA resp. MPD, comment out resp. omit the dmix.format line and change the one for mpd with format to "44100:*:2".

Note: Crossfading between files decoded at two different bit depths (say, one mp3 and one 16 bit flac) does not work unless conversion is active.

Control MPD with lirc

There are already some clients designed for communications between lircd and MPD, however, as far as the practical use, they are not very useful since their functions are limited.

It is recommended to use mpc with irexec. mpc is a command line player which only sends the command to MPD and exits immediately, which is perfect for irexec, the command runner included in lirc. What irexec does is that it runs a specified command once received a remote control button.

First of all, please setup your remotes as referred to the Lirc article.

Local (with separate mpd user)

When run as its own user as per the wiki instructions, mpd will be unable to send sound to another user's pulseaudio server. Rather than setting up pulseaudio as a system-wide daemon, a practice strongly discouraged by upstream, you can instead configure mpd to use pulseaudio's tcp module to send sound to localhost:

First, uncomment the tcp module in /etc/pulse/default.pa or $XDG_CONFIG_HOME/default.pa (typically ~/.config/pulse/default.pa) and set 127.0.0.1 as an allowed IP address; the home directory takes precedence:

Enable the output in mpd; you should now have a working local mpd, usable by all users whose pulseaudio servers allow sound from 127.0.0.1.

Remote

As with any PulseAudio-enabled program, mpd can send sound over the network. The complete PulseAudio system is not required on the server running mpd; libpulse is the only requirement to act as a source and is already a dependency of mpd.

In order to send audio from mpd to another computer follow the directions above, editing /etc/mpd.conf on the server running mpd using the IP address of the target computer and /etc/pulse/default.pa or $XDG_CONFIG_HOME/default.pa (typically ~/.config/pulse/default.pa) on the target computer using the IP address of the server.

Once this is done, the server's mpd source should show up on the target computer while playing or paused as a normal source able to be rerouted and controlled as usual; there will be no visible source on the target while mpd is stopped.

Cue Files

No additional steps are needed for cue support in mpd since 0.17. MPD has its own integrated parser which works with both external and embedded cuesheets.
For example, the command mpc load albumx/x.cue loads the file music_directory/albumx/x.cue as playlist; or in the case of an CUESHEET tag, mpc load albumx/x.flac.

HTTP Streaming

Since version 0.15 there is a built-in HTTP streaming daemon/server that comes with MPD. To activate this server simply set it as output device in mpd.conf:

Then to listen to this stream simply open the URL of your mpd server (along with the specified port) in your favorite music player. Note: You may have to specify the file format of the stream using an appropriate file extension in the URL. For example, using Winamp 5.5, You would use http://192.168.1.2:8000/mpd.ogg rather than http://192.168.1.2:8000/.