Skip to content

Commit

Permalink
music: fix opus base gain extraction
Browse files Browse the repository at this point in the history
I have no idea how it ended up this mangled.
  • Loading branch information
OxygenCobalt committed Jan 14, 2024
1 parent dea0ee1 commit b483391
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/src/main/java/org/oxycblt/auxio/music/metadata/TagWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit b483391

Please sign in to comment.