Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume is set to 100% at start op play of mp3 file when replay_gain_handler is set to mixer #1785

Closed
janui opened this issue Apr 20, 2023 · 2 comments

Comments

@janui
Copy link

janui commented Apr 20, 2023

Bug report

Describe the bug

When a mp3 file is played the MPD volume is set to 100% regardless of its previous level when 'replay_gain_handler' is set to 'mixer'. The volume remains at 100% until a non-mp3 file containing replay gain flags is played. The volume is then adjusted (incorrectly, see Bug report #1778).
Playing webradios has the same effect.
The effects could costly or even dangerous by damaging your HiFi kit or your ears.
When 'replay_gain_handler' is omitted it works correctly.

Expected Behavior

A mp3 file should be played at the previously set MPD volume. Replay gain for mp3's is implemented by setting the volume directly in the metadata, as such there are no special replay gain flags for mp3. The volume should not be changed.

Actual Behavior

MPD: open socket
OK

MPD Protocol: setvol 50
OK

MPD Protocol: currentsong
file: USB/MUSICBOX/Annie Lennox/Diva/01 Why.mp3
Last-Modified: 2015-01-01T22:06:12Z
Format: 44100:24:2
Artist: Annie Lennox
AlbumArtist: Annie Lennox
Title: Why
Album: Diva
Track: 1
Date: 1992
Genre: Rock
Composer: Annie Lennox
Label: RCA
Time: 293
duration: 293.479
Pos: 101
Id: 105
OK

MPD Protocol: status
volume: 50
repeat: 0
random: 0
single: 0
consume: 0
partition: default
playlist: 59
playlistlength: 105
mixrampdb: 0
state: stop
xfade: 2
song: 101
songid: 105
nextsong: 102
nextsongid: 106
OK

Bash: amixer -c 1 sget Digital
Simple mixer control 'Digital',0
Capabilities: pvolume pswitch
Playback channels: Front Left - Front Right
Limits: Playback 0 - 207
Mono:
Front Left: Playback 171 [83%] [-18.00dB] [on]
Front Right: Playback 171 [83%] [-18.00dB] [on]

MPD Protocol: play
OK

MPD Protocol: currentsong
file: USB/MUSICBOX/Annie Lennox/Diva/01 Why.mp3
Last-Modified: 2015-01-01T22:06:12Z
Format: 44100:24:2
Artist: Annie Lennox
AlbumArtist: Annie Lennox
Title: Why
Album: Diva
Track: 1
Date: 1992
Genre: Rock
Composer: Annie Lennox
Label: RCA
Time: 293
duration: 293.479
Pos: 101
Id: 105
OK

MPD Protocol: status
volume: 100
repeat: 0
random: 0
single: 0
consume: 0
partition: default
playlist: 59
playlistlength: 105
mixrampdb: 0
state: play
xfade: 2
song: 101
songid: 105
time: 3:293
elapsed: 2.783
bitrate: 320
duration: 293.479
audio: 44100:24:2
nextsong: 102
nextsongid: 106
OK

Bash: amixer -c 1 sget Digital
Simple mixer control 'Digital',0
Capabilities: pvolume pswitch
Playback channels: Front Left - Front Right
Limits: Playback 0 - 207
Mono:
Front Left: Playback 207 [100%] [0.00dB] [on]
Front Right: Playback 207 [100%] [0.00dB] [on]

MPD: close socket
OK

Version

uname -a
Linux pi4 6.1.13-1-rpi-ARCH #1 SMP PREEMPT Thu Feb 23 12:17:10 MST 2023 aarch64 GNU/Linux
mpd -V
Music Player Daemon 0.23.12 (0.23.12)

Configuration

...
replaygain "track"
...
audio_output {
name "snd_rpi_hifiberry_dacplus"
type "alsa"
device "hw:1,0"
mixer_control "Digital"
mixer_type "hardware"
mixer_device "hw:1"
replay_gain_handler "mixer"
auto_resample "no"
auto_format "no"
enabled "yes"
}

Log

No logs attached. The problem is consistent and reproducible.

@MaxKellermann
Copy link
Member

The volume should not be changed

No, this is wrong. A mp3 file should not play at the same volume level as the previous song - this would imply that a mp3 song will play at different volume levels, depending on which song precedes it.

If you rely solely on the volume adjustments in the MP3 header, that's fine - but from MPD's perspective, that's a song without ReplayGain information, and that's correct.

Maybe what you need to do is configure a replaygain_missing_preamp. Unfortunately, the guy who submitted this feature many years ago didn't document it. I'll add documentation for it to the user manual, and that will resolve your issue.

@janui
Copy link
Author

janui commented May 23, 2023

Dear Max,

Thanks for your answer. However, your answer still does not explain why the MPD volume level jumps from its preset level to 100% when a mp3 file is played.

MPD seems to be forgetting its reference volume level. It appears that when replay_gain_handler is set to mixer and replay_gain is enabled MPD assumes that volume control is disabled (or set at 100%).
This is not consistent with the processing of replay_gain when replay_gain_handler is not set. In this case the preset volume level is maintained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants