Merge pull request #670 from OxygenCobalt/dev

Quick opus gain fix
This commit is contained in:
Alexander Capehart 2024-01-13 22:17:36 -07:00 committed by GitHub
commit 7a5ba6b20d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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