(Created page with "=== ALSA dmix Output === There's a couple of different configuration options here. The easiest is to edit mpd.conf as follows:<br /><pre><br />audio_output {<br />      ty...")
 
(remove html tags from code bloc)
 
Line 1: Line 1:
 
=== ALSA dmix Output ===
 
=== ALSA dmix Output ===
  +
There's a couple of different configuration options here. The easiest is to edit mpd.conf as follows:
   
  +
<pre>
There's a couple of different configuration options here. The easiest is to edit mpd.conf as follows:<br /><pre><br />audio_output {<br />      type                    "alsa"<br />      name                    "Sound Card"<br />      options                 "dev=dmixer"<br />      device                  "plug:dmix"<br />}
 
  +
audio_output {
  +
      type                    "alsa"
  +
      name                    "Sound Card"
  +
      options                 "dev=dmixer"
  +
      device                  "plug:dmix"
  +
}
 
</pre>
 
</pre>
   
 
An additional option is as follows:<br />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 <code>ipc_*</code> stuff well, because without it only root would be able to dmix other sounds.
 
An additional option is as follows:<br />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 <code>ipc_*</code> stuff well, because without it only root would be able to dmix other sounds.
   
  +
Sample <tt>/etc/asound.conf</tt> configuration:
Sample <tt>/etc/asound.conf</tt> configuration:<br /><pre><br />pcm.dmixer { <br />  type dmix <br />  ipc_key 1024<br />  ipc_key_add_uid false<br />  ipc_perm 0666            # mixing for all users<br />  slave { <br />      pcm "hw:0,0" <br />      period_time 0 <br />      period_size 1024 <br />      buffer_size 8192<br />      rate 44100<br />  }<br />  bindings { <br />      0 0 <br />      1 1 <br />  } <br />} 
 
   
  +
<pre>
pcm.dsp0 { <br />  type plug <br />  slave.pcm "dmixer" <br />} 
 
  +
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 {
pcm.!default { <br />  type plug <br />  slave.pcm "dmixer" <br />} 
 
  +
  type plug
  +
  slave.pcm "dmixer"
  +
  +
pcm.!default {
  +
  type plug
  +
  slave.pcm "dmixer"
  +
   
  +
pcm.default {
pcm.default { <br /> type plug <br /> slave.pcm "dmixer" <br />} 
 
  +
  type plug
  +
 slave.pcm "dmixer"
  +
   
ctl.mixer0 { <br />  type hw <br />  card 0 <br />}
+
ctl.mixer0 {
  +
  type hw
  +
  card 0
  +
}
 
</pre>
 
</pre>
   
Line 21: Line 58:
 
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)
 
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:<br /><pre><br />mixer_type "software"<br /></pre>
+
An alternative to this ALSA configuration would be to simply add the following to /etc/mpd.conf and restart mpd:
  +
  +
<pre><br />mixer_type "software"<br /></pre>
   
 
====Create asound.conf====
 
====Create asound.conf====
Line 27: Line 66:
 
First, the following lines are required in <tt>/etc/asound.conf</tt>. Note the software mixer mpdvol with the name "MPD". This will be used when editing the <tt>/etc/mpd.conf</tt> file. The software mixer "softvol" controls the level of the other sounds on your computer, and has the generic name of "Software".
 
First, the following lines are required in <tt>/etc/asound.conf</tt>. Note the software mixer mpdvol with the name "MPD". This will be used when editing the <tt>/etc/mpd.conf</tt> file. The software mixer "softvol" controls the level of the other sounds on your computer, and has the generic name of "Software".
   
  +
<pre>
<pre><br /># the sound card<br />pcm.real {<br />type hw<br />card 0<br />device 0<br />}
 
  +
# the sound card
  +
pcm.real {
  +
type hw
  +
card 0
  +
device 0
  +
}
   
  +
# the ipc stuff is needed for permissions, etc.
# the ipc stuff is needed for permissions, etc.<br />pcm.dmixer {<br />type dmix<br />ipc_key 1024<br />ipc_perm 0666<br />slave.pcm "real"<br />slave {<br />  period_time 0<br />  period_size 1024<br />  buffer_size 8192<br />  rate 44100  <br />}<br />bindings {<br />  0 0<br />  1 1 <br />}<br />}
 
  +
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
  +
}
  +
}
   
ctl.dmixer {<br />type hw<br />card 0<br />}
+
ctl.dmixer {
  +
type hw
  +
card 0
  +
}
   
  +
# software volume
# software volume<br />pcm.softvol {<br />type softvol<br />slave.pcm "dmixer"<br />control {<br />  name "Software"<br />  card 0<br />}<br />}
 
  +
pcm.softvol {
# mpd volume control<br />pcm.mpdvol {<br />type softvol<br />slave.pcm "dmixer"<br />control {<br />  name "MPD"<br />  card 0<br />}<br />}
 
  +
type softvol
# ctrl for mpd volume<br />ctl.mpdvol {<br />type hw<br />card 0<br />}
 
  +
slave.pcm "dmixer"
  +
control {
  +
  name "Software"
  +
card 0
  +
}
  +
}
  +
# mpd volume control
  +
pcm.mpdvol {
  +
type softvol
  +
slave.pcm "dmixer"
  +
control {
  +
  name "MPD"
  +
  card 0
  +
}
  +
}
  +
# ctrl for mpd volume
  +
ctl.mpdvol {
  +
type hw
  +
card 0
  +
}
   
  +
# input
# input<br />pcm.input {<br />      type dsnoop<br />      ipc_key 3129398<br />      ipc_key_add_uid false<br />      ipc_perm 0660<br />      slave.pcm "810"<br />}
 
  +
pcm.input {
  +
      type dsnoop
  +
      ipc_key 3129398
  +
      ipc_key_add_uid false<
  +
      ipc_perm 0660
  +
      slave.pcm "810"
  +
}
   
  +
# duplex device
# duplex device<br />pcm.duplex {<br />      type asym<br />      playback.pcm "softvol"<br />      capture.pcm "input"<br />}
 
  +
pcm.duplex {
  +
      type asym
  +
      playback.pcm "softvol"
  +
      capture.pcm "input"
  +
}
   
# default devices<br />pcm.!default {<br />type plug<br />slave.pcm "duplex"<br />}
+
# default devices
  +
pcm.!default {
  +
type plug
  +
slave.pcm "duplex"
  +
}
   
# for oss devices<br />pcm.dsp0 {<br />type plug<br />slave.pcm "duplex"<br />}
+
# for oss devices
  +
pcm.dsp0 {
  +
type plug
  +
slave.pcm "duplex"
  +
}
 
</pre>
 
</pre>
   
Line 50: Line 154:
 
The <tt>device</tt> line in the <tt>audio_output</tt> below should be set to the device name for the mpd volume that was specified above in the <tt>asound.conf</tt> file.<br />Note that the <tt>mixer_device</tt> line uses the same device as the <tt>device</tt> line in the <tt>audio_output</tt> section, but that the <tt>mixer_control</tt> line should be set to the NAME that was given in <tt>asound.conf</tt>.
 
The <tt>device</tt> line in the <tt>audio_output</tt> below should be set to the device name for the mpd volume that was specified above in the <tt>asound.conf</tt> file.<br />Note that the <tt>mixer_device</tt> line uses the same device as the <tt>device</tt> line in the <tt>audio_output</tt> section, but that the <tt>mixer_control</tt> line should be set to the NAME that was given in <tt>asound.conf</tt>.
   
  +
<pre>
<pre><br />audio_output {<br />      type                    "alsa"<br />      name                    "Alsa Software Volume"<br /> device            "mpdvol"<br />}
 
  +
audio_output {
  +
      type                    "alsa"
  +
      name                    "Alsa Software Volume"
  +
device            "mpdvol"
  +
}
 
</pre>
 
</pre>
   
 
and
 
and
   
  +
<pre>
<pre><br />mixer_type                      "alsa"<br />mixer_device                    "mpdvol"<br />mixer_control                   "MPD"<br /></pre>
 
  +
mixer_type                      "alsa"
  +
mixer_device                    "mpdvol"
  +
mixer_control                   "MPD"
  +
</pre>
   
   
Line 62: Line 175:
 
=== ALSA select digital audio out ===<br />Example to select the digital audio output (not the (default?) analog out):
 
=== ALSA select digital audio out ===<br />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.<br /><pre><br />pcm.intel8x0 {<br /> type hw<br /> card 0<br />}
+
.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.
<br />pcm.!default {<br /> type plug<br /> slave.pcm "spdif"<br /> slave.rate 48000<br />}
 
   
  +
<pre>
ctl.intel8x0 {<br /> type hw<br /> card 0<br />}
 
  +
pcm.intel8x0 {
  +
 type hw
  +
card 0
  +
}
  +
pcm.!default {
  +
 type plug
  +
 slave.pcm "spdif"
  +
 slave.rate 48000
  +
}
  +
  +
ctl.intel8x0 {
  +
type hw
  +
 card 0
  +
}
 
</pre>
 
</pre>
  +
Now the corresponding entry in mpd.conf. The device name must match the slave.pcm name in the .asoundrc file:
   
  +
<pre>
Now the corresponding entry in mpd.conf. The device name must match the slave.pcm name in the .asoundrc file:<br /><pre><br />audio_output {<br />      type                    "alsa"<br />      name                    "My ALSA Device"<br />      device                  "spdif"<br />}
 
  +
audio_output {
  +
      type                    "alsa"
  +
      name                    "My ALSA Device"
  +
      device                  "spdif"
  +
}
 
</pre>
 
</pre>
   
Line 74: Line 206:
   
   
Another example, how to activate the 2nd device on the first audio hardware:<br />Hercules Fortissimo IV ice1724 with kernel 2.6.26 and Alsa 1.0.17:<br />.asoundrc:<br /><pre><br />pcm.ice1724 {<br />  type hw<br />  card 0<br />}
 
   
 
Another example, how to activate the 2nd device on the first audio hardware:<br />Hercules Fortissimo IV ice1724 with kernel 2.6.26 and Alsa 1.0.17:<br />.asoundrc:
pcm.!iec958 {<br />  type plug<br />  slave.pcm "hw:0,1"<br />}
 
  +
  +
<pre>
  +
pcm.ice1724 {
  +
  type hw
  +
  card 0
  +
}
  +
  +
pcm.!iec958 {
  +
  type plug
  +
  slave.pcm "hw:0,1"
  +
}
   
pcm.!default {<br />  type plug<br />  slave.pcm "hw:0,1"<br />}
+
pcm.!default {
  +
  type plug
  +
  slave.pcm "hw:0,1"
  +
}
   
ctl.ice1724 {<br />  type hw<br />  card 0<br />}
+
ctl.ice1724 {
  +
  type hw
  +
  card 0
  +
}
 
</pre>
 
</pre>
  +
Now the corresponding entry in mpd.conf. The 'plughw' did the trick, it matches the "hw:0,1" entry from the Alsa .asoundrc file&nbsp;!
   
  +
<pre>
Now the corresponding entry in mpd.conf. The 'plughw' did the trick, it matches the "hw:0,1" entry from the Alsa .asoundrc file&nbsp;!<br /><pre><br />audio_output {<br />      type                    "alsa"<br />      name                    "My ALSA Device"<br />      device                  "plughw:0,1"<br />}
 
  +
audio_output {
  +
      type                    "alsa"
  +
      name                    "My ALSA Device"
  +
      device                  "plughw:0,1"
  +
}
 
</pre>
 
</pre>
   
Line 92: Line 246:
 
In /etc/mpd.conf:
 
In /etc/mpd.conf:
   
  +
<pre>
<pre><br />audio_output {<br />      type                    "alsa"<br />      name                    "SPDIF"<br />      device                  "cards.pcm.iec958"<br />}
 
  +
audio_output {
  +
      type                    "alsa"
  +
    name                    "SPDIF"
  +
      device                  "cards.pcm.iec958"
  +
}
 
</pre>
 
</pre>
   

Latest revision as of 19:24, 10 March 2019

ALSA dmix Output[edit | edit source]

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 ipc_* 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[edit | edit source]

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:

<br />mixer_type "software"<br />

Create asound.conf[edit | edit source]

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".

# the sound card
pcm.real {
    type hw
    card 0
    device 0
}

# the ipc stuff is needed for permissions, etc.
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
    }
}

ctl.dmixer {
    type hw
    card 0
}

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

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

# duplex device
pcm.duplex {
      type asym
      playback.pcm "softvol"
      capture.pcm "input"
}

# default devices
pcm.!default {
      type plug
      slave.pcm "duplex"
}

# for oss devices
pcm.dsp0 {
    type plug
    slave.pcm "duplex"
}

====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 line in the audio_output section, but that the mixer_control line should be set to the NAME that was given in asound.conf.

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)[edit | edit source]

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

Community content is available under CC-BY-SA unless otherwise noted.