Open estshorter opened 6 years ago
Please explain "A value from mpc volume varies by itself after playing a song". In my understanding, a changing volume value is the very point of this setting.
What I want to say is that behavior of issue 1 is inconsistent with that using only software volume.
The following is command log using only software volume.
$ mpc volume 100
volume:100% repeat: off random: off single: off consume: off
$ mpc play
no_sound rg-10
[playing] #1/1 0:00/5:00 (0%)
volume:100% repeat: off random: off single: off consume: off
$ mpc volume
volume:100%
This says the volume of 100% corresponds the value based on replaygain tag (-10dB) for software volume. However, when using hardware volume, the volume of 100% correponds to 0dB as shown in the first post.
Audio output section of mpd.conf for software volume:
audio_output {
type "alsa"
name "alsa"
device "hw:0,0"
# dop "no"
#mixer_device "default"
#mixer_control "Digital"
mixer_type "software"
format "*:32:*"
#replay_gain_handler "mixer"
replay_gain_handler "software"
}
As far as I understand, replay_gain_handler "mixer"
means that MPD should change the mixer volume setting, so that the reported behaviour is indeed intended and not an anomaly.
Moreover one has to note that mixer_type
and replay_gain_handler
are orthogonal settings, so it makes no sense to compare
mixer_type "software"
replay_gain_handler "software"
with
mixer_type "hardware"
replay_gain_handler "mixer"
This said, there is a clear problem with the latter setting ("hardware" mixer, and "mixer" replay gain) in the computation of the scale factor in MPD/src/ReplayGainInfo.cxx at https://github.com/MusicPlayerDaemon/MPD/blob/9f6af4f2cc1f806bbbd32b18f64beb01a218cb6d/src/ReplayGainInfo.cxx#L32 Here the desired correction expressed as an acoustic pressure level (gain=-10dB) is convert into a sound pressure ratio p/p0 = 10**(-10/20) = 0.316.
The problem is that this factor is applied to the 0...100 normalised volume scale scale used by MPD, which for the alsa hardware mixer is neither linear in the sound pressure nor the sound pressure level, see https://github.com/MusicPlayerDaemon/MPD/blob/9f6af4f2cc1f806bbbd32b18f64beb01a218cb6d/src/mixer/plugins/volume_mapping.c#L21-L27
There is no easy answer to this problem, because the type of mapping from normalised volume to the acoustic pressure/acoustic pressure level cannot be queried programmatically. (I found no API for manipulating the mapping, nor for operating in terms of dB instead of normalised volume. I'm not an author of MPD, so please correct me if I'm wrong.)
At present I would suggest to keep all things as they are, and maybe add a note to the docs that replay_gain_handler mixer
is not accurate in terms of dB attenuation for some types of mixers.
For the future a volume control API in terms of sound pressure level attenuation (i.e. defined on a dB scale and not an arbitrary normalised volume range) could be implemented.
@miccoli Thank you for your clear explanation. I understand that the issue 1 is an intentional behaviour.
Issues
When replay_gain_hander is specified as "mixer",
mpc volume
varies by itself after playing a songamixer get Digital
mpd: 0.20.17 outputs: alsa
Detail
I prepared a test file (nosound, replaygain: -10db). 01 no_sound rg-10.zip
Command log when playing the test file is as follows.
As you can see above, initial volume (100%) changed to 30% after
mpc play
. This is not the case when using only software volume; the volume is constant.Moreover, the dB value written in the replaygain tag (-10dB) is quite different from that obtained by
amixer get Digital
(-31dB). The latter value should be around -10dB.MPD verbose log
mpd.conf
mpd -V