Fix OpenSubsonic ReplayGain loudness calculation (#2893)
authorOzGav <gavnosp@hotmail.com>
Sun, 28 Dec 2025 08:27:25 +0000 (16:27 +0800)
committerGitHub <noreply@github.com>
Sun, 28 Dec 2025 08:27:25 +0000 (09:27 +0100)
commit2a0fb69653870d1f6f07e9acfa013820700047bb
treea8ac5312dd32bbfa15105f370ce9956d5cf1d579
parent31f00545c66bf80fbbec15131ad78a87acb011fd
Fix OpenSubsonic ReplayGain loudness calculation (#2893)

* Fix OpenSubsonic ReplayGain loudness calculation

The OpenSubsonic provider was passing raw ReplayGain gain values
(in dB) directly to set_loudness(), but set_loudness() expects
integrated loudness values (in LUFS).

This caused tracks with ReplayGain tags to show incorrect loudness
values when accessed via OpenSubsonic/Navidrome. For example, a
quiet track with +0.39 dB gain was being stored as 0.39 LUFS
instead of -18.39 LUFS, resulting in massive gain reduction
(-17.39 dB) instead of a small boost.

Fixed by converting ReplayGain values to loudness before storing:
  Loudness (LUFS) = -18 - Gain (dB)

This matches the ReplayGain 2.0 specification and how the
filesystem provider handles ReplayGain tags.

Only affects users connecting to Navidrome/Subsonic servers.
Users with local filesystem music were not affected.

* Remove unnecessary comment

---------

Co-authored-by: Claude <noreply@anthropic.com>
music_assistant/providers/opensubsonic/sonic_provider.py