SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2012-01-24 06:43:40

ivanovnegro
Ivan #000000
From: unstable madness
Registered: 2011-06-02
Posts: 5,422

The ultimate MPD guide

Added the steps to install and configure alsaequal.

Feb 12 2012 My mpd.conf (old version) and .asoundrc, if needed to compare. Also added how to configure mpdscribble, for the real beginners. wink

Apr 30 2012 Made a fault, it is commenting the line about the user in MPD conf not uncommenting. wink

Jul 12 2012 Added new code to the mpd.conf and updated my mpd.conf.

May 09 2013 Following symlinks and updated mpd.conf.

Introduction

I know we have many guides how to set up MPD properly but most of the info is a bit older or outdated and many users had enough problems to configure MPD.

I will therefore try to make a guide that I can also use as a personal reference for the future. @VastOne is one of the people that motivated me to write it down. See it also as an attempt to show some new users that it is not that difficult.

I use Debian Sid but I think most of it can be applied to a standard #! Statler system regardless of the February or November release.

I hope to be able to encourage you to try MPD out as it is a really great music program that can fulfill most of your music needs.

I assume most users know already what MPD is and also its advantages.

Let us begin

First of all you have to install MPD:

apt-get install mpd

I recommend to install mpc too:

apt-get install mpc

it is a command line based client for MPD that should help you to control it without any special GUI client, that comes later. It helped me personally for the first steps.

We will set up MPD as a user service and not as a system service, that is important because you will be able to run MPD as your user and not as root. I think that is a better choice and also more secure. That will also help us with the reported problems that MPD by default always starts as a system service and on boot and even as root what we want to avoid.
Because of that we will disable MPD to start as a system daemon and to start it from boot with:

sudo service mpd stop

and

sudo update-rc.d mpd disable 

Now we will make a new directory in the home folder for the configuration files of MPD and the playlists, we will not touch the system wide configuration file in
/etc/mpd.conf, that will avoid all the problems with permissions and it should be more useful to have the files in your home folder:

mkdir -p ~/.mpd/playlists

Now we will copy the configuration file to our home folder:

gunzip -c /usr/share/doc/mpd/examples/mpd.conf.gz > ~/.mpd/mpd.conf

And now we will create all the needed files for it:

touch ~/.mpd/{mpd.db,mpd.log,mpd.pid,mpdstate}

Now is the time when we will actually edit the MPD configuration file. Use your editor of choice, I use Mousepad because I am on Xfce:

mousepad ~/.mpd/mpd.conf

I will begin with the directories, that is the first important step and I will use my setup as an example, you have to change of course your directory and your user name. The music directory has to point to your music directory. My music is on an external hard drive:

music_directory        "/media/David Extern/Música"

playlist_directory     "/home/david/.mpd/playlists"

db_file            "/home/david/.mpd/tag_cache"

log_file        "/home/david/.mpd/mpd.log"

pid_file        "/home/david/.mpd/mpd.pid"

state_file        "/home/david/.mpd/mpdstate"

Now comes the tricky part. My setup looks like this, I did not change the username here, I only commented the line because I do not use MPD as a system service, it looks like this:

#user                "mpd"

That might be a part of a discussion, there are some different approaches.

The second important thing is your sound output. I use the default, Alsa, as on most Debian systems:

audio_output {
    type        "alsa"
    name        "My ALSA Device"
    device        "hw:0,0"    # optional
    format        "44100:16:2"    # optional
    mixer_device    "default"    # optional
    mixer_control    "PCM"        # optional
    mixer_index    "0"        # optional
}

But if you use Pulse, you have to uncomment the Alsa section and go to the Pulse section and it has to look like this:

audio_output {
  type    "pulse"
  name    "MPD"                                                                 
# server    "remote_server"   # optional
# sink    "remote_server_sink"  # optional
}

That should be all. Save the file and close your editor.

To start MPD just type:

mpd

I think it should automatically add all your music to your music directory, if not type:

mpc update

That is what I used. MPD will now take some time and import all your music but it is doing it rather fast, I have approximately 50.000 songs in my database and it was a breeze even on an external drive.

Now we will create a desktop file to start MPD automatically on boot, that is what I do:

mousepad ~/.config/autostart/mpd.desktop

Add these lines:

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Music Player Daemon
Comment=Server for playing audio files
Exec=mpd
StartupNotify=false
Terminal=false
Hidden=false

Now MPD will start always as a daemon in the background on boot. It will also run as your user and not as root. I know some users reported this problem often here in the forums.

Some advanced options

You can of course change some settings to your personal likings in the MPD configuration file.
But I will speak of the newest version of MPD I use, it is version 0.16.5-1 because I am on Sid and not version 0.15.12-1.1 like on Stable/Statler but there is only one difference. It is this line if you are on Testing/Unstable:

#auto_update    "yes"

I have it disabled but if you want you can use it to autoupdate your music library.

Ok, some other features I use and you can use too of course.

mixer_type            "software"

I have this enabled because that means it does not interfere with other application's volume when I change the volume e.g. from ncmpcpp.

You can set up replay gain with MPD, a great feature some music apps in Linux does not offer:

replaygain            "track"

And before I forget, a must have feature for me and for all real music lovers is gapless of course, you can enable it from this line:

gapless_mp3_playback            "yes"

I still did not say what app to use as a client, I think most of you know about the many different kinds of clients for MPD. I use ncmpcpp, you can of course install another one or multiple ones without to care about your music library, that is a great thing with MPD. This way you can try them all without importing always your music.

Some extra sound options

I am a music lover and also need some better sound. You maybe noticed that MPD does not come with an equalizer but such a thing is essential to me for my personal music experience.
You can use an EQ with MPD, maybe there are some other methods but I use this as described already in my MOC how-to, there you can find how to set it up on your system. I use alsaequal.

Edit: Regardless of my MOC how-to, I will explain how to install and configure alsaequal as requested by some users.

That is only for Testing/Unstable users. If you want to install alsaequal on Stable, you should compile it from source.
First we will install the required packages:

apt-get install libasound2-plugin-equal

Now we will create a .asoundrc file in your home directory but as your user not as root:

mousepad .asoundrc

That will open a blank text file, put this in:

ctl.equal {
          type equal;
        }

        pcm.plugequal {
          type equal;
          # Modify the line below if you don't
          # want to use sound card 0.
          slave.pcm "plug:dmix";
        }

        # pcm.equal {
          # Or if you want the equalizer to be your
          # default soundcard uncomment the following
          # line and comment the above line.
        pcm.!default {
          type plug;
          slave.pcm plugequal;
        }

Save and close the file.
To make use of the new sound configuration we will reload Alsa as root:

alsa force-reload

Now we can make use of the new EQ with:

alsamixer -D equal

Here I will speak how to use that with MPD.

Do not forget this is only for Alsa as it is what I use as my sound output.

You have to change the Alsa line in your MPD configuration file to make to look it like this:

audio_output {
    type        "alsa"
    name        "My ALSA EQ"
    auto_resample    "no"
    use_mmap        "yes"
    device        "plug:plugequal"
    format        "44100:16:2"    # optional
    mixer_device    "default"    # optional
    mixer_control    "PCM"        # optional
    mixer_index    "0"        # optional
}

Then it is important to change a thing to be possible to use the EQ and to have sound with MPD as I had some problems in the past. If not properly configured MPD will refuse to connect to the audio device.
You have to add MPD to the audio group if not already done before. As root:

usermod -aG audio mpd

This command will prove if MPD is in that group:

cat /etc/group | grep audio

Now you can use MPD with alsaequal!

Additional stuff

If you use ncmpcpp like I do then you have the possibility for some fancy visualizations, at least on Testing/Unstable with version 0.5.6-2.
To be able to use them you have to go back to the MPD configuration file and add these lines to your audio output:

audio_output {
        type                    "fifo"
        name                    "My FIFO"
        path                    "/tmp/mpd.fifo"
} 

You can of course use your keyboard to control MPD without a GUI or because you prefer it this way. Some clients can provide that feature natively. Here comes why I installed the client mpc. You can control MPD with some basic commands and making a short cut for your keyboard. Really simple:

mpc pause

will pause MPD and

mpc play

will play music etc. etc.

You can use Conky with MPD too. We have a mega thread about this here.

For LastFM users there is lastfmsubmitd and lastmp, the second one is needed specially for MPD. You can of course use another LastFM client for MPD, there are many choices.

Edit: I actually recommend to use mpdscribble instead of lastfmsubmitd. It is lighter and works better. It caches the played songs offline too.
Lastmp with lastfmsubmitd is buggy in my experience.

Mpdscribble

For the sake of completeness I will describe how to get mpdscribble to work with MPD because I am amazed that it works so good.
First we have to install it as usual:

apt-get install mpdscribble  

Then we will begin to edit the /etc/mpdscribble.conf:

mousepad /etc/mpdscribble.conf

Only change this lines according to your username and password:

[last.fm]
url = http://post.audioscrobbler.com/
username = ivanovnegro
password = yourpassword
# 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

You will see, you can even scrobble to LibreFM.

To activate the daemon:

mousepad /etc/default/mpdscribble

and change this line to look like mine:

# Whether to enable system wide daemon
MPD_SYSTEMWIDE=1

Restart the thing as root with:

service mpdscribble restart

and it will work, after a reboot it will also start automatically.
I am sure you could also configure it a bit different than I did but in my case that was the best way for me.


I hope it can help some users to configure MPD the easy way. If you have suggestions, questions or whatever, just post it or PM me and we can discuss.

Feel free to add new and additional information to make this thread a good reference on MPD.


Thanks again to @VastOne for the inspiration and the Arch Wiki that helped me to collect some info.

Issues

If you have an error message like this:

listen: bind to '0.0.0.0:6600' failed: Address already in use (continuing anyway, because binding to '[::]:6600' succeeded)

You have to change this line in your mpd.conf:

# For network
#bind_to_address                "localhost"

to this:

bind_to_address                       "127.0.0.1"

Symlinks

It is time now. My external disk is full and before I use a bigger one I have to split my library in two.
MPD does only one music library but you can use symlinks, very easy and that's it.

I will show just my example. My library is on an external disk and my second music directory is in my home folder. I will make my music directory in my home folder a part of my main MPD music library to solve the problem.

I will just cd into my main music directory:

cd media/David Extern/Música

then I will make a symlink for the second directory to be integrated into my main music library:

ln -s ~/Musik

That is all. Apply it to your personal configuration. Now ~/Musik is a part of media/David Extern/Música and can be accessed from it.
We have to change one minor setting in the mpd.conf:

# Symbolic link behavior ######################################################
#
# If this setting is set to "yes", MPD will discover audio files by following 
# symbolic links outside of the configured music_directory.
#
follow_outside_symlinks	"yes"
#
# If this setting is set to "yes", MPD will discover audio files by following
# symbolic links inside of the configured music_directory.
#
follow_inside_symlinks		"yes"
#

As you see, I applied both options just in case because you can decide to follow symlinks outside or inside the configured music directory, splendid!
The last thing is to update your MPD music library as usual.

That makes MPD use multiple music libraries even though using a different way than other music players.

More sources

Alsaequal project site
Configure alsaequal on Debian

Important note: Because I resigned from this forum, I no longer will be able to update my how-to. There are many many more things I wanted to add, like streaming etc.
So, if anybody feels brave enough, just add more to the how-to when needed, do not close it, expand on it. You have also to update some new methods of starting services when systemd comes to Debian.

As it is now, it is of course a great guide and totally valid on any Debian based system.

I will still occasionally help out.

Fork it, take over!  cool

Last edited by ivanovnegro (2013-10-29 17:53:29)

Offline

Be excellent to each other!

#2 2012-01-24 06:45:31

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 10,163
Website

Re: The ultimate MPD guide

Excellent How To Sir Ivan...

Very nicely done!

Added to Quick Reference


VSIDO | SolusOS

Words That Build Or Destroy

Offline

#3 2012-01-24 07:22:27

ivanovnegro
Ivan #000000
From: unstable madness
Registered: 2011-06-02
Posts: 5,422

Re: The ultimate MPD guide

Thank you for your feedback!

Offline

#4 2012-01-24 09:19:05

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: The ultimate MPD guide

MPD, the one CLI music player i'll (probably) ever consider using over MOC. thanks for this howto ivanov, i'm sure it'll come in handy one day.

Offline

#5 2012-01-24 13:11:05

Athos
#! CrunchBanger
Registered: 2011-09-28
Posts: 108

Re: The ultimate MPD guide

Many thanks inanovnegro!

This will be helpfull... big_smile

Offline

#6 2012-01-24 13:13:18

Milozzy
#! Die Hard
Registered: 2011-02-22
Posts: 622
Website

Re: The ultimate MPD guide

Great guide ivano!!

But tell me: is there a way to have pulseaudio and an equalizer at the same time?

Offline

#7 2012-01-24 16:21:04

gutterslob
#! Resident Bum
Registered: 2009-11-03
Posts: 2,977

Re: The ultimate MPD guide

Very nice, Mr. Ivan


Some thoughts:

To avoid potential WTF moments when configuring the eq for alsa, it might be wise to tell people to actually install alsaequal first =P

On Debian, it should be:

# apt-get install libasound2-plugin-equal

Replace apt-get with aptitude if you swing that way.



Also, best to inform folks of the command to launch the equalizer, which would be;

alsamixer -D equal

I know it's already stated on the project page, but it'd be best to put em in your guide as well, me thinks.
Including a sample ~/.asoundrc would be good too.

Last edited by gutterslob (2012-01-24 16:24:50)


Point & Squirt

Offline

#8 2012-01-24 16:36:11

pvsage
Internal Affairs
From: North Carolina
Registered: 2009-10-18
Posts: 11,949

Re: The ultimate MPD guide

@Slob & Ivan:  Are you guys using Testing or Unstable?  I don't see libasound2-plugin-equal in my APT cache on Stable.


I'm a moderator here.  How are we doing?  Feedback is encouraged.

Offline

#9 2012-01-24 16:47:02

gutterslob
#! Resident Bum
Registered: 2009-11-03
Posts: 2,977

Re: The ultimate MPD guide

^ Sage
I can confirm that it's on both Testing and Unstable. No idea about Stable, sorry

Edit:
Seems there's no package for Squeeze
http://packages.debian.org/search?keywo … ugin-equal

You can try "apt-cache search alsaequal" to see if there's an equivalent. If not, temporarily add testing repos and get it (or use apt-pinning and keep testing repos) or just grab teh deb from debian's package page after you've confirmed you have all the dependencies.

Last edited by gutterslob (2012-01-24 16:49:03)


Point & Squirt

Offline

#10 2012-01-24 16:57:41

pvsage
Internal Affairs
From: North Carolina
Registered: 2009-10-18
Posts: 11,949

Re: The ultimate MPD guide

Not really that massive an issue for me; just pointing out it ain't in Squeeze.  (Already ran a few apt-cache searches...there's an equalizer for LADSPA, but I know nothing about LADSPA...)  Besides, if I'm gonna EQ, I'll probably do it in hardware, old-school.


I'm a moderator here.  How are we doing?  Feedback is encouraged.

Offline

#11 2012-01-24 17:22:54

gutterslob
#! Resident Bum
Registered: 2009-11-03
Posts: 2,977

Re: The ultimate MPD guide

^That's what I do on my desktop as well. Though I use OSS instead of ALSA there (OSS doesn't have any EQ, so external headphone amp or death). EQ works wonders on the netbook's anemic output with earbuds, though.

I'm not surprised the package is not in Stable. Debian's always been slow on the uptake of these sort of packages. Heck, even Unstable only got alsaequal in early 2011.


Point & Squirt

Offline

#12 2012-01-24 17:47:25

el_koraco
#!/loony/bun
From: inside Ed
Registered: 2011-07-25
Posts: 4,748

Re: The ultimate MPD guide

On some Stable systems, mpd will throw up an error on install about not connecting. So after you've disabled it from starting as a system service, go to /etc/default/mpd and change the line

START_MPD=true

to false.

Offline

#13 2012-01-24 19:19:56

ivanovnegro
Ivan #000000
From: unstable madness
Registered: 2011-06-02
Posts: 5,422

Re: The ultimate MPD guide

@milozzy: An EQ with Pulse Audio not sure on Debian, there was a package for Ubuntu but I do not know if that is compatible with Debian, I used it and I know @VastOne also.

@Slobby: Thank you for the feedback, will include that info also. I provided the links from my MOC how-to where I explained the alsequal stuff but you are right, would be better to describe the steps here.

@pvsage: The link from the Debian Forums describes the compiling procedure for alsaequal on Stable. At the moment it is just for Testing/Unstable.

Offline

#14 2012-01-24 19:35:42

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 10,163
Website

Re: The ultimate MPD guide

Yes, I still use the PulseAudo Equalizer on Debian...

You can install it with no issue with the debs from here.  I used the Maverick one.  Gdebi will tell you if you do not have the correct dependencies installed.


VSIDO | SolusOS

Words That Build Or Destroy

Offline

#15 2012-01-24 19:45:30

Milozzy
#! Die Hard
Registered: 2011-02-22
Posts: 622
Website

Re: The ultimate MPD guide

VastOne wrote:

Yes, I still use the PulseAudo Equalizer on Debian...

You can install it with no issue with the debs from here.  I used the Maverick one.  Gdebi will tell you if you do not have the correct dependencies installed.

mmm really really interesting!! Thank you very much!!

Offline

#16 2012-01-26 18:13:37

sunfizz98
Carbonated Orange Juice
From: su terminal
Registered: 2011-05-12
Posts: 1,876
Website

Re: The ultimate MPD guide

Excellent howto!  I recommend ncmpcpp in case mpc is too minimal.

Offline

#17 2012-01-26 23:48:12

ivanovnegro
Ivan #000000
From: unstable madness
Registered: 2011-06-02
Posts: 5,422

Re: The ultimate MPD guide

^ Sure. Mpc is just there to use it when I do not have immediate access to a client via short cuts.

Offline

#18 2012-01-27 00:15:20

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 10,163
Website

Re: The ultimate MPD guide

That is the beauty of MPD, so many choices...  I actually like all the gui apps for it.  Sonata, Ario and GMPC are exceptional apps..


VSIDO | SolusOS

Words That Build Or Destroy

Offline

#19 2012-01-27 03:57:54

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,843
Website

Re: The ultimate MPD guide

ivanovnegro wrote:

I hope to be able to encourage you to try MPD out as it is a really great music program that can fulfill most of your music needs.
I assume most users know already what MPD is and also its advantages.

Actually... I've looked at some of the docs for mpd in the past, and couldn't quite get what the advantage was of having a daemon to play your music, instead of a cli app like mplayer or moc. This looks like a great chance to try MPD, so could someone give us a bit of a pep talk on what it's good for? smile


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#20 2012-01-27 04:07:51

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 10,163
Website

Re: The ultimate MPD guide


VSIDO | SolusOS

Words That Build Or Destroy

Offline

#21 2012-01-27 10:53:56

Milozzy
#! Die Hard
Registered: 2011-02-22
Posts: 622
Website

Re: The ultimate MPD guide

VastOne wrote:

That is the beauty of MPD, so many choices...  I actually like all the gui apps for it.  Sonata, Ario and GMPC are exceptional apps..

Totally agree!
These days I am really torn between GMB and MPD + GMPC as my full feature musci player.

Too bad Sonata is dead.

Offline

#22 2012-01-27 15:39:25

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,843
Website

Re: The ultimate MPD guide

Thanks VastOne, but I'm afraid I still don't understand what's useful about having your music sent out from a server, to be picked up by a client, instead of just playing the files with a regular media player. Sorry to be obtuse... sad


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#23 2012-01-27 16:58:57

ivanovnegro
Ivan #000000
From: unstable madness
Registered: 2011-06-02
Posts: 5,422

Re: The ultimate MPD guide

^ I will say why I use it. It is just fast as hell when you really want to important a BIG music library and it is light on resources. The beauty of running it in the background is that it can run even without X.

Of course you can play your files locally, e.g. with MOC, but there is the problem, when I use the "lousy" search feature and want to import big directories into the playlist MOC won't be fast, with MPD it is a one "click" on whatever and regardless of the size of the music directory, immediately it will pull all the music to a playlist. No heavy loads and waiting, the CPU and RAM stands normal.

The advantage at the end is maybe more for us with an enormous music library, imagine more than 50.000 songs or more. I can assure you if you have 100.000 tracks forget all the players like Banshee etc. to be able to run flawlessly. So, if you have less, could be you are just happy with what you have and for me, MOC is really good but without all that features MPD and a client of your choice can give me, tagging, searching, libraries, LastFM etc. MPD even with a GUI client runs smooth. MPD is for power users regarding music I would say.

You have just to try it.

Offline

#24 2012-01-27 16:59:08

Milozzy
#! Die Hard
Registered: 2011-02-22
Posts: 622
Website

Re: The ultimate MPD guide

johnraff wrote:

Thanks VastOne, but I'm afraid I still don't understand what's useful about having your music sent out from a server, to be picked up by a client, instead of just playing the files with a regular media player. Sorry to be obtuse... sad

Well, I like MPD on my eeepc because I can select my music with a client, close the client and let mpd playing the music in background, without any other application around...This mean low ram and cpu usage, very useful for a low hardware machine and of course excellent if you want to maximize your battery life.

Offline

Help fund CrunchBang, donate to the project!

#25 2012-01-27 17:45:36

Milozzy
#! Die Hard
Registered: 2011-02-22
Posts: 622
Website

Re: The ultimate MPD guide

ivanovnegro wrote:

^ I will say why I use it. It is just fast as hell when you really want to important a BIG music library and it is light on resources. The beauty of running it in the background is that it can run even without X.

Of course you can play your files locally, e.g. with MOC, but there is the problem, when I use the "lousy" search feature and want to import big directories into the playlist MOC won't be fast, with MPD it is a one "click" on whatever and regardless of the size of the music directory, immediately it will pull all the music to a playlist. No heavy loads and waiting, the CPU and RAM stands normal.

The advantage at the end is maybe more for us with an enormous music library, imagine more than 50.000 songs or more. I can assure you if you have 100.000 tracks forget all the players like Banshee etc. to be able to run flawlessly. So, if you have less, could be you are just happy with what you have and for me, MOC is really good but without all that features MPD and a client of your choice can give me, tagging, searching, libraries, LastFM etc. MPD even with a GUI client runs smooth. MPD is for power users regarding music I would say.

You have just to try it.

We post almost at the same time...and yea, I totally agree with you. I have a large music collection and this is the secondo reason why I use MPD.
The only players that let me enjoy my music library aside from MPD are quodlibet and gmusicbrowser.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo