harbor run -t scale-ai/hil-bench-swe_21-full_infoharbor download scale-ai/hil-bench-swe_21-full_info##Scanner gain handling does not fully align across supported tag formats##
Description
The metadata scanner currently reads gain-related tags but does not consistently interpret all formats used in modern audio files. Different tagging schemes may represent loudness adjustment values differently, and the scanner should recognize these formats while keeping a consistent loudness reference with existing outputs.
Steps to reproduce 1. Add an audio file (for example, OPUS) that includes gain-related tags in a format different from the traditional ReplayGain fields. 2. Run a library scan. 3. Check the track/album gain reported by the application or by the metadata layer.
Actual Behavior
Expected Behavior
r128_track_gain and r128_album_gain.No new interfaces are introduced.
Existing behavior is surfaced through the metadata tag accessors in scanner/metadata/metadata.go, including:
Tags.RGTrackGain() and Tags.RGAlbumGain() for gain valuesTags.RGTrackPeak() and Tags.RGAlbumPeak() for peak valuesR128 gain tag values are Q7.8 fixed-point integers and must be converted to dB by dividing by 256.0, then applying a fixed +4.637 dB offset to align with the application's ReplayGain reference. ReplayGain gain tag values are already in the application's reference and must be used directly as parsed floats (no additional offset).
If a gain tag key contains multiple values, the scanner must use the last value in the list for parsing and normalization.
When both formats are present, the preference policy is field-specific: album gain must prefer ReplayGain, while track gain must prefer R128. If the preferred format for a field is absent, the scanner must use the other format.