music: fix opus base gain extraction

I have no idea how it ended up this mangled.
This commit is contained in:
Alexander Capehart 2024-01-13 22:15:17 -07:00
parent dea0ee1432
commit b4833918cf
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -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}")