Installing Music Player Daemon

Linux Audio Introduction

Choices abound with Linux distributions.  I have tried Ubuntu, Fedora, Damn Small Linux, Gentoo, Debian, Puppy Linux, Lubuntu, Bodhi Linux, Linux Mint and a few others.  The best way to test drive just about any Linux distro is to get yourself a Pendrive that is at least 1 Gig and go to PendriveLinux, they have everything you need to download and run Linux straight from your USB Pendrive stick. With a little time and patience you can settle on your own personal favorite flavor of Linux.

For audio, look for a Linux distro with a very small footprint which works very well out of the box and does not have Pulse Audio installed by default. However if Pulse-Audio is the default it can be removed easily. Ideally, the only thing that should be done is to install the real-time kernel and set up ALSA for real-time processing.  From there you can have your choice of audio front ends like Clementine or DeadBeef to play music, or install Music Player Daemon and operate the software remotely from another computer or even a iTouch or Android phone.

What is Music Player Daemon?

Music Player Daemon is a program that runs in the background and gives the absolute best sound of any software I have heard to date.  The best thing about MPD is that you can install a client [the interface that controls MPD] on any type of computer; a PC, a Mac,  iTouch, iPhone, Android product or Linux computer.  Having a client on another computer makes MPD the best choice for a headless computer.  Set-up can be a little difficult but it all boils down to about 7 steps to be off and running.

Looking for a traditional music player? Try DeadBeef, its pretty much the Foobar of Linux imo, you can even import Foobar's eq settings. Clementine is also great!

These instructions assume you already are aware of:
Synaptic Package Manager, Terminal, and your distributions text editor.

How to install Music Player Daemon     [click on the pics to enlarge]

1)Go to Synaptic Package Manager and type in mpd then search, right mouse button ->Mark for Installation...repeat for gmpc
Afterwards select Apply.




2)Create 2 Music Directories, by default the Music directory already exists, if not
Open a terminal window and type
sudo mkdir Music
sudo mkdir Playlist

Copy and paste your music files into the folder. Once the music files are loaded into the new folders, type the command below in a terminal window to open up permissions.

sudo chmod 755 -R Music
sudo chmod 755 -R Playlist

2a)For external HD music, NTFS formatted hard drive might have permission problems...in that case see bottom of tutorial to resolve.

cd ../../media
cd [NameofYourHD]
ls [shows directories within external HD]
sudo chmod 755 -R [name of music directory]

Use pwd to find the path as shown, then use that path for the mpd.conf file


3)aplay -l to find sound card - USB
example: You would enter 0,1 for this device in step 4b.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
card 0: NVidia [HDA NVidia], device 1: Conexant Digital [Conexant Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

Note commands in terminal window and results that return. [ls, pwd, ifconfig, aplay -l]


3a)aplay -L to find SPDIF out, always called IEC958

Note: For SPDIF out you must un-mute the port first.  Do the following:

Type: alsamixer in terminal, then press F5 for [ALL].  Use the arrow key and press the letter "M" on your keyboard to un-mute everything, then Esc.


Use > arrow to highlight and letter M to un-mute



4)Change file, remove the comment [#]
sudo gedit /etc/default/mpd
example: This last line had a # mark, just remove and save [was #MPDCONF...]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## The configuration file location for mpd:
MPDCONF=/etc/mpd.conf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

5)Change file, add music path, add playlist path, add soundcard
sudo gedit /etc/mpd.conf

In new terminal
cd to your music directory then type pwd to find path.
Next, cd to playlist directory then type pwd to find path. 

5a.
In the REQUIRED PATHS section of the mpd.conf file replace the information for music directory with your information [path] and playlist.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
music_directory "/home/Music"
playlist_directory "/home/Playlist"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 



Scroll down a bit and comment out the localhost line and use your IP address instead for GMPC


5b.
Scroll down to AUDIO OUTPUT section of mpd.conf file, uncomment this section [remove #]. Modify the line for device with plug and the soundcard numbers
add the lines for auto_resample, use_mmap, buffers, and periods.  See MPD wiki 'Tuning' for explanations.  See Alsa wiki in ref to buffer and period times and sizes.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#

audio_output {

	        type "alsa"
name "my ALSA device"
                device "hw:1,0"                            #<-----For SPDIF replace "hw:1,0" with "cards.pcm.iec958"
                mmap_emulation "true"
fragment_size "4096"
}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Save the file, then
sudo killall mpd
sudo mpd

6)Create file for internet radio 

sudo gedit 

add the http of your favorite station and save as a .m3u file. Save As then save it in your Playlist directory.

-or-

if you already have a .pls file from your favorite radio station just type

sudo cp [your .pls file] [whatevername.m3u] <~~~This will copy the playlist file into a new .m3u file for MPD

For example; sudo cp groovesalad130.pls groove.m3u

Then type;

sudo chmod 775 -R Playlist[from your home directory]


7)Restart MPD and update database with music
In terminal type:
sudo killall mpd

sudo mpd


Now go to your Sound & Video application under your main menu and select GMPC [Linux]or Ario [PC, Mac], or use MPod [iTouch] and follow the 2-3 steps to connect to mpd. 

Configure GMPC, add the ip address as shown then connect. Then select Server->Update Database




Done!


Note:

I found that if you don't have a network connection at startup MPD will fail to start.  To work around this I added a line in a start-up script that starts MPD about 15 seconds after boot. See "Setting up ALSA" for details.

Also after all the tweaks I have done, adding the Real-Time Kernel, ALSA tweaks etc. I find that the biggest difference in sound can be obtained by adjusting the buffer size.  Sound can go from thin and flat to lush and full....this is great for final tuning to the perfect sound that synergizes with the rest of your gear.


Upsampling with Sox Sample-Rate Converter


Open Synaptics Package Manager and install Sox.

Add or replace the following lines below the original output lines. If added below the original audio_output lines you will have 2 methods to output. One normal and one upsampled....make sure you toggle one OFF before playing music.

#
audio_output {
type "pipe"
name "upsample-sox"
format "44100:32:2"
command "sox -traw -esi -b32 -c2 -r44100 - -talsa -esi -b24 -c2 -D hw:1,0 rate 88200 2>/dev/null"
mmap_emulation     "true"
fragment_size     "4096"
}



Upgrade to the latest Alpha version of MPD


1)Add repository and key to Synaptic Package Manager

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C116A57C

Then,

sudo add-apt-repository ppa:gmpc-trunk/mpd-trunk

Go to Synaptic Package Manager first refresh and then search for mpd, right mouse button Mark for Upgrade then Apply. Repeat for gmpc. 

Go here for details https://launchpad.net/~gmpc-trunk/+archive/mpd-trunk

NOTE: In order to get .wav .aif .aiff file to play you need to add these lines to the mpd.conf file

decoder {
    plugin "sndfile"
    enabled "no"
}




Permission problems when mounting an external NTFS hard drive?

In mpd.conf file run the pid as the same owner of the NTFS....

cd ../../media
cd (name)
ls -al to find owner of external hard drive

In mpd.conf file change owner

pid_file "/home/[user]/.mpd/pid"
Create a .mpd directory in the home directory
chmod 755 .mpd
touch ~/.mpd/pid