Closed bartkl closed 1 month ago
What you are seeing is the expected (designed) behaviour of mpd.
One workaround is to perform the channel balance adjustment before the stream is passed to the sound card, using alsalib. Create the file /etc/asound.conf
with the following contents:
pcm.channelbalance {
type plug
slave.pcm "hw:IQaudIODAC" # change this for different card
slave.channels 2
ttable.0.0 1.00 # left channel at 100%
ttable.1.1 0.94 # right channel at 94%
}
Adjust the ttable.1.1
value according to how much you wish to "move" the sound to the left,
and set the slave.pcm value appropriately for your card.
Modify your mpd.conf to use the new ALSA pcm definition; something like:
audio_output {
type "alsa"
name "Balanced Sound Card"
device "channelbalance"
mixer_type "hardware"
mixer_device "hw:IQaudIODAC" # change this for different card
mixer_control "Digital"
}
Restart mpd so that it reads the new ALSA configuration, and hopefully the stereo balance will then be more to your liking, even as you use the mpd volume control.
Works like a charm. Thank you!
Hmm it doesn't work after all. I must have tested it sloppily.
What does work is when I change the relative volume levels, MPD picks up on that. But the issue still remains that as soon as I change volume using MPD, the channel volumes equalize. Maybe this is the case because we still point to the same mixer device (hw:IQaudIODAC
in your example), and we should add some kind of virtual mixer device that sets the volume of the channelbalance
?
Thanks.
PS I'm still curious why this is intented/designed MPD behavior. If I change the balance of my speakers on my amp I would be surprised if it jumpd to center as soon as I turn the volume up or down.
when I change the relative volume levels
I didn't explain the "channelbalance" pcm solution very well. The idea is that you use that instead of changing the relative volume levels in alsamixer. We know that MPD will undo any channel volume difference applied by the mixer, so we apply the desired attenuation of the right channel before the stream reaches the mixer. So (in very imprecise language), say MPD requests volume of 60%, and the channelbalance pcm has reduced the right channel to 90%; in that case the mixer changes the left channel to 100% 60% == 60%; and the right channel to 90% 60% == 54%. So the left channel is still higher volume than the right, and there is still a perceived balance shift to the left. Those numbers will not be exact, because it all depends on exactly how each element calculates volume (taking into account the logarithmic relationship between perceived loudness and output power, different algorithms and parameters, etc).
we should add some kind of virtual mixer device
To apply such a solution to the channelbalance
pcm would require writing a new ALSA plugin; so it would probably be simpler to code a solution for the MPD ALSA mixer plugin and raise a PR here.
There are two options for introducing virtual mixer that completely removes the need for a channelbalance pcm:
mixer_type "software"
in the mpd.conf audio_output
entry and then use alsamixer as before to set individual channel levels with the "Digital" control.softvol
plugin to create a user control associated with your sound card (such a control is conventionally called "PCM", and if you choose that name then MPD will use it by default). Again set the balance using "Digital" and use "PCM" as the volume level control. For example (assuming your card is card 1, change that if necessary) in /etc/asound.conf
:pcm.softvol {
type softvol
slave.pcm "hw:1,0"
control {
name "PCM Playback Volume"
card 1
}
}
You will need to open the pcm once to cause ALSA to create the "PCM" control, so do
aplay -D plug:softvol /usr/share/sounds/alsa/Front_Center.wav
Now modify mpd.conf so that it uses the "softvol" pcm and control called PCM
audio_output {
type "alsa"
name "Balanced Sound Card"
device "plug:softvol"
mixer_type "hardware"
mixer_device "hw:1" # change this for different card
mixer_control "PCM"
}
and then restart MPD.
To remove the PCM control if you later decide not to use this solution, delete the pcm.softvol
entry from /etc/asound.conf
, then do: (change the 1
to match your card)
alsactl clean 1 'name="PCM Playback Volume"'
The idea is that you use that instead of changing the relative volume levels in alsamixer. We know that MPD will undo any channel volume difference applied by the mixer
Of course, that makes perfect sense. I honestly feel like I understood that before and got tangled up in a brainfart, haha. Anyways, I increased the difference in volume levels and yes, it is clearly working.
Thanks so much for the detailed explanation, for the alternatives as well. I might look into those later, but I'm pretty happy with this solution as it stands.
Bug report
Describe the bug
I am running MPD on a Raspberry Pi and use ALSA for my device output. I've got the setup working fine basically, but I've stumbled upon an issue.
I've rearranged my room and now I can't sit perfectly between my speakers anymore. To compensate for this you would usually adjust the center balance on the amp, but on my amp this feature doesn't work anymore (it's old).
So, I solved it in
alsamixer
. I increased the volume of the left channel to compensate for my sitting a bit to the right.This solution works great, until I change my volume. If I change the volume in any MPD client, it equalizes the volumes of both channels. I suspect MPD calls the ALSA API such that it overwrites the volume levels of both channels with the new value?
Thanks!
Expected Behavior
If I increase or decrease the volume, I expect MPD to adjust each channel with the same fixed amount, not have it alter the relative volume levels per channel.
Actual Behavior
When changing the volume with MPD, it does not just change the volume, it also equalizes the volume levels of both channels.
Version
mpd --version
Configuration
mpd.conf
Log
n/a