playback: accept non-r128 tags on opus files
Apparently certain taggers just write replaygain information to opus files regardless of the standard. Have to accomodate it. Resolves #372.
This commit is contained in:
parent
811447126c
commit
d6e7b99e1f
2 changed files with 28 additions and 27 deletions
|
@ -1,5 +1,11 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## dev
|
||||||
|
|
||||||
|
#### What's Improved
|
||||||
|
- Accept `REPLAYGAIN_*` adjustment information on OPUS files alongside
|
||||||
|
`R128_*` adjustments.
|
||||||
|
|
||||||
## 3.0.3
|
## 3.0.3
|
||||||
|
|
||||||
#### What's New
|
#### What's New
|
||||||
|
|
|
@ -23,7 +23,6 @@ import com.google.android.exoplayer2.Player
|
||||||
import com.google.android.exoplayer2.Tracks
|
import com.google.android.exoplayer2.Tracks
|
||||||
import com.google.android.exoplayer2.audio.AudioProcessor
|
import com.google.android.exoplayer2.audio.AudioProcessor
|
||||||
import com.google.android.exoplayer2.audio.BaseAudioProcessor
|
import com.google.android.exoplayer2.audio.BaseAudioProcessor
|
||||||
import com.google.android.exoplayer2.util.MimeTypes
|
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
@ -168,32 +167,28 @@ constructor(
|
||||||
|
|
||||||
// Most ReplayGain tags are formatted as a simple decibel adjustment in a custom
|
// Most ReplayGain tags are formatted as a simple decibel adjustment in a custom
|
||||||
// replaygain_*_gain tag.
|
// replaygain_*_gain tag.
|
||||||
if (format.sampleMimeType != MimeTypes.AUDIO_OPUS) {
|
textTags.id3v2["TXXX:$TAG_RG_TRACK_GAIN"]
|
||||||
textTags.id3v2["TXXX:$TAG_RG_TRACK_GAIN"]
|
?.run { first().parseReplayGainAdjustment() }
|
||||||
?.run { first().parseReplayGainAdjustment() }
|
?.let { trackGain = it }
|
||||||
?.let { trackGain = it }
|
textTags.id3v2["TXXX:$TAG_RG_ALBUM_GAIN"]
|
||||||
textTags.id3v2["TXXX:$TAG_RG_ALBUM_GAIN"]
|
?.run { first().parseReplayGainAdjustment() }
|
||||||
?.run { first().parseReplayGainAdjustment() }
|
?.let { albumGain = it }
|
||||||
?.let { albumGain = it }
|
textTags.vorbis[TAG_RG_ALBUM_GAIN]
|
||||||
textTags.vorbis[TAG_RG_ALBUM_GAIN]
|
?.run { first().parseReplayGainAdjustment() }
|
||||||
?.run { first().parseReplayGainAdjustment() }
|
?.let { trackGain = it }
|
||||||
?.let { trackGain = it }
|
textTags.vorbis[TAG_RG_TRACK_GAIN]
|
||||||
textTags.vorbis[TAG_RG_TRACK_GAIN]
|
?.run { first().parseReplayGainAdjustment() }
|
||||||
?.run { first().parseReplayGainAdjustment() }
|
?.let { albumGain = it }
|
||||||
?.let { albumGain = it }
|
// Opus has it's own "r128_*_gain" ReplayGain specification, which requires dividing the
|
||||||
} else {
|
// adjustment by 256 to get the gain. This is used alongside the base adjustment
|
||||||
// Opus has it's own "r128_*_gain" ReplayGain specification, which requires dividing the
|
// intrinsic to the format to create the normalized adjustment. This is normally the only
|
||||||
// adjustment by 256 to get the gain. This is used alongside the base adjustment
|
// tag used for opus files, but some software still writes replay gain tags anyway.
|
||||||
// intrinsic to the format to create the normalized adjustment. That base adjustment
|
textTags.vorbis[TAG_R128_TRACK_GAIN]
|
||||||
// is already handled by the media framework, so we just need to apply the more
|
?.run { first().parseReplayGainAdjustment() }
|
||||||
// specific adjustments.
|
?.let { trackGain = it / 256f }
|
||||||
textTags.vorbis[TAG_R128_TRACK_GAIN]
|
textTags.vorbis[TAG_R128_ALBUM_GAIN]
|
||||||
?.run { first().parseReplayGainAdjustment() }
|
?.run { first().parseReplayGainAdjustment() }
|
||||||
?.let { trackGain = it / 256f }
|
?.let { albumGain = it / 256f }
|
||||||
textTags.vorbis[TAG_R128_ALBUM_GAIN]
|
|
||||||
?.run { first().parseReplayGainAdjustment() }
|
|
||||||
?.let { albumGain = it / 256f }
|
|
||||||
}
|
|
||||||
|
|
||||||
return if (trackGain != 0f || albumGain != 0f) {
|
return if (trackGain != 0f || albumGain != 0f) {
|
||||||
Adjustment(trackGain, albumGain)
|
Adjustment(trackGain, albumGain)
|
||||||
|
|
Loading…
Reference in a new issue