music: fix opus base gain extraction
I have no idea how it ended up this mangled.
This commit is contained in:
parent
dea0ee1432
commit
b4833918cf
1 changed files with 9 additions and 6 deletions
|
@ -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}")
|
||||
|
|
Loading…
Reference in a new issue