- 0 Talk
-
Alsa
Contents |
ALSA dmix Output
Edit
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
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
Edit
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
Edit
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"
Unfortunately there are many differences between various mpd versions.
In old mpd versions, the mixer_type/device/control part needs to be in global section scope, not within audio_output section.
Also, in newer versions (~ 0.16), mixer_type "alsa" (and "oss"?) has been changed to "hardware". See your mpd log files to check for any trouble in mixer setup, e.g.
config: option 'mixer_device' on line 105 was not recognized
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
Edit
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
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/Bit_Perfect_Digital_Audio_Playback