Alsa

ALSA dmix Output
There's a couple of different configuration options here. The easiest is to edit mpd.conf as follows:

audio_output { type                    "alsa" name                    "Sound Card" options                 "dev=dmixer" device                  "plug:dmix" }

An additional option is as follows: When you want to allow users to dmix their played sounds to mpd output sound if you run mpd from init scripts you need either to configure ALSA dmix plugin, either don't forget to set the  stuff well, because without it only root would be able to dmix other sounds.

Sample /etc/asound.conf configuration:

pcm.dmixer { type dmix ipc_key 1024 ipc_key_add_uid false ipc_perm 0666            # mixing for all users slave { pcm "hw:0,0" period_time 0 period_size 1024 buffer_size 8192 rate 44100 }  bindings { 0 0      1 1  } }

pcm.dsp0 { type plug slave.pcm "dmixer" } pcm.!default { type plug slave.pcm "dmixer" }

pcm.default { type plug slave.pcm "dmixer" }

ctl.mixer0 { type hw  card 0 }

ALSA MPD software volume control
The following is what is needed to get a working software volume control that can be controlled by alsamixer, as well as the mpd volume control. This allows mpd to be lowered in volume, but not the other sounds on your system (or vice-versa)

An alternative to this ALSA configuration would be to simply add the following to /etc/mpd.conf and restart mpd:

mixer_type "software"

Create asound.conf
First, the following lines are required in /etc/asound.conf. Note the software mixer mpdvol with the name "MPD". This will be used when editing the /etc/mpd.conf file. The software mixer "softvol" controls the level of the other sounds on your computer, and has the generic name of "Software".

pcm.real { type hw   card 0 device 0 }
 * 1) the sound card

pcm.dmixer { type dmix ipc_key 1024 ipc_perm 0666 slave.pcm "real" slave { period_time 0 period_size 1024 buffer_size 8192 rate 44100 }   bindings { 0 0       1 1    } }
 * 1) the ipc stuff is needed for permissions, etc.

ctl.dmixer { type hw   card 0 }

pcm.softvol { type softvol slave.pcm "dmixer" control { name "Software" card 0 } } pcm.mpdvol { type softvol slave.pcm "dmixer" control { name "MPD" card 0 } } ctl.mpdvol { type hw   card 0 }
 * 1) software volume
 * 1) mpd volume control
 * 1) ctrl for mpd volume

pcm.input { type dsnoop ipc_key 3129398 ipc_key_add_uid false< ipc_perm 0660 slave.pcm "810" }
 * 1) input

pcm.duplex { type asym playback.pcm "softvol" capture.pcm "input" }
 * 1) duplex device

pcm.!default { type plug slave.pcm "duplex" }
 * 1) default devices

pcm.dsp0 { type plug slave.pcm "duplex" }
 * 1) for oss devices

Edit mpd.conf
Next, the following lines need to be edited in /etc/mpd.conf:

The device line in the audio_output below should be set to the device name for the mpd volume that was specified above in the asound.conf file. Note that the mixer_device line uses the same device as the device</tt> line in the audio_output</tt> section, but that the mixer_control</tt> line should be set to the NAME that was given in asound.conf</tt>.

audio_output { type                    "alsa" name                    "Alsa Software Volume" device            "mpdvol" }

and

mixer_type                      "alsa" mixer_device                    "mpdvol" mixer_control                   "MPD"

You will need to restart the mpd daemon before these settings to work. If they aren't working, you may try rebooting your system. You should see a listing for the volume for MPD using gnome-alsamixer or alsamixer. You can also control the volume setting using any other client for mpd (mpc, ncmpc, gmpc, sonata, etc.). It doesn't affect the other sounds on your system!

ALSA select digital audio out
Example to select the digital audio output (not the (default?) analog out):

.asoundrc (usually already present in home directory). This example is for a nforce3 board. Settings for other chip sets will vary, see Alsa-Project for more examples.

pcm.intel8x0 { type hw   card 0 } pcm.!default { type plug slave.pcm "spdif" slave.rate 48000 }

ctl.intel8x0 { type hw   card 0 } Now the corresponding entry in mpd.conf. The device name must match the slave.pcm name in the .asoundrc file:

audio_output { type                    "alsa" name                    "My ALSA Device" device                  "spdif" }

May this save somebody some time...

Another example, how to activate the 2nd device on the first audio hardware: Hercules Fortissimo IV ice1724 with kernel 2.6.26 and Alsa 1.0.17: .asoundrc:

pcm.ice1724 { type hw   card 0 }

pcm.!iec958 { type plug slave.pcm "hw:0,1" }

pcm.!default { type plug slave.pcm "hw:0,1" }

ctl.ice1724 { type hw   card 0 } Now the corresponding entry in mpd.conf. The 'plughw' did the trick, it matches the "hw:0,1" entry from the Alsa .asoundrc file !

audio_output { type                    "alsa" name                    "My ALSA Device" device                  "plughw:0,1" }

ALSA select digital audio out (bit-perfect)
The examples above might produce bit-perfect output, however I've tested the example below and can confirm that it works with a CMI 8768 card. I've successfully played 96KHz FLAC with mpd using this configuration.

In /etc/mpd.conf:

audio_output { type                    "alsa" name                    "SPDIF" device                  "cards.pcm.iec958" }

For an explanation of bit-perfect audio, go here: http://www.mythtv.org/wiki/index.php/Bit_Perfect_Digital_Audio_Playback