diff --git a/app/src/main/java/org/oxycblt/auxio/music/metadata/TagWorker.kt b/app/src/main/java/org/oxycblt/auxio/music/metadata/TagWorker.kt index 6a5880f7d..2167c195d 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/metadata/TagWorker.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/metadata/TagWorker.kt @@ -105,12 +105,15 @@ private class TagWorkerImpl( format.initializationData.isNotEmpty() && format.initializationData[0].size >= 18) { val header = format.initializationData[0] - val gain = header[1].toInt() or ((header[0].toInt() shl 8) and 0xFF) - logD("Obtained opus base gain: ${gain / 256f} dB") - rawSong.replayGainTrackAdjustment = - rawSong.replayGainTrackAdjustment?.plus(gain / 256f) - rawSong.replayGainAlbumAdjustment = - rawSong.replayGainAlbumAdjustment?.plus(gain / 256f) + val gain = (((header[16]).toInt() and 0xFF) or ((header[17].toInt() shl 8))) / 256f + logD("Obtained opus base gain: $gain dB") + if (gain != 0f) { + logD("Applying opus base gain") + rawSong.replayGainTrackAdjustment = + (rawSong.replayGainTrackAdjustment ?: 0f) + gain + rawSong.replayGainAlbumAdjustment = + (rawSong.replayGainAlbumAdjustment ?: 0f) + gain + } } } else { logD("No metadata could be extracted for ${rawSong.name}")