playback: make replaygain always-on

Remove the "Off" ReplayGain setting, as it is mostly meaningless.

Users who don't want ReplayGain can remove the tags from their files.
No efficiency benefits either since the audio processor is always
disabled without replaygain tags. It is better not to confuse users
who do have ReplayGain but wonder why it is not working on their
files because the setting is off.
This commit is contained in:
OxygenCobalt 2022-08-11 11:41:52 -06:00
parent b104dd151d
commit ee68e7ffe9
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
10 changed files with 14 additions and 22 deletions

View file

@ -2,6 +2,10 @@
## dev ## dev
#### What's Changed
- ReplayGain can now no longer be disabled. Remove ReplayGain tags from
files if such functionality is not desired.
## 2.6.1 ## 2.6.1
#### What's New #### What's New

View file

@ -108,8 +108,8 @@ object IntegerTable {
/** Sort.ByDateAdded */ /** Sort.ByDateAdded */
const val SORT_BY_DATE_ADDED = 0xA118 const val SORT_BY_DATE_ADDED = 0xA118
/** ReplayGainMode.Off */ /** ReplayGainMode.Off (No longer used but still reserved) */
const val REPLAY_GAIN_MODE_OFF = 0xA110 // const val REPLAY_GAIN_MODE_OFF = 0xA110
/** ReplayGainMode.Track */ /** ReplayGainMode.Track */
const val REPLAY_GAIN_MODE_TRACK = 0xA111 const val REPLAY_GAIN_MODE_TRACK = 0xA111
/** ReplayGainMode.Album */ /** ReplayGainMode.Album */

View file

@ -67,6 +67,8 @@ class ExoPlayerBackend(private val inner: MediaStoreBackend) : Indexer.Backend {
val songs = mutableListOf<Song>() val songs = mutableListOf<Song>()
val total = cursor.count val total = cursor.count
// LEFTOFF: Make logic more consistent?
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
// Note: This call to buildAudio does not populate the genre field. This is // Note: This call to buildAudio does not populate the genre field. This is
// because indexing genres is quite slow with MediaStore, and so keeping the // because indexing genres is quite slow with MediaStore, and so keeping the

View file

@ -21,8 +21,6 @@ import org.oxycblt.auxio.IntegerTable
/** Represents the current setting for ReplayGain. */ /** Represents the current setting for ReplayGain. */
enum class ReplayGainMode { enum class ReplayGainMode {
/** Do not apply ReplayGain. */
OFF,
/** Apply the track gain, falling back to the album gain if the track gain is not found. */ /** Apply the track gain, falling back to the album gain if the track gain is not found. */
TRACK, TRACK,
/** Apply the album gain, falling back to the track gain if the album gain is not found. */ /** Apply the album gain, falling back to the track gain if the album gain is not found. */
@ -34,7 +32,6 @@ enum class ReplayGainMode {
/** Convert an int [code] into an instance, or null if it isn't valid. */ /** Convert an int [code] into an instance, or null if it isn't valid. */
fun fromIntCode(code: Int): ReplayGainMode? { fun fromIntCode(code: Int): ReplayGainMode? {
return when (code) { return when (code) {
IntegerTable.REPLAY_GAIN_MODE_OFF -> OFF
IntegerTable.REPLAY_GAIN_MODE_TRACK -> TRACK IntegerTable.REPLAY_GAIN_MODE_TRACK -> TRACK
IntegerTable.REPLAY_GAIN_MODE_ALBUM -> ALBUM IntegerTable.REPLAY_GAIN_MODE_ALBUM -> ALBUM
IntegerTable.REPLAY_GAIN_MODE_DYNAMIC -> DYNAMIC IntegerTable.REPLAY_GAIN_MODE_DYNAMIC -> DYNAMIC

View file

@ -65,12 +65,6 @@ class ReplayGainAudioProcessor(context: Context) : BaseAudioProcessor() {
* based off Vanilla Music's implementation, but has diverged to a significant extent. * based off Vanilla Music's implementation, but has diverged to a significant extent.
*/ */
fun applyReplayGain(metadata: Metadata?) { fun applyReplayGain(metadata: Metadata?) {
if (settings.replayGainMode == ReplayGainMode.OFF) {
logD("ReplayGain not enabled")
volume = 1f
return
}
val gain = metadata?.let(::parseReplayGain) val gain = metadata?.let(::parseReplayGain)
val preAmp = settings.replayGainPreAmp val preAmp = settings.replayGainPreAmp
@ -79,8 +73,6 @@ class ReplayGainAudioProcessor(context: Context) : BaseAudioProcessor() {
// ReplayGain is configurable, so determine what to do based off of the mode. // ReplayGain is configurable, so determine what to do based off of the mode.
val useAlbumGain = val useAlbumGain =
when (settings.replayGainMode) { when (settings.replayGainMode) {
ReplayGainMode.OFF -> throw IllegalStateException()
// User wants track gain to be preferred. Default to album gain only if // User wants track gain to be preferred. Default to album gain only if
// there is no track gain. // there is no track gain.
ReplayGainMode.TRACK -> gain.track == 0f ReplayGainMode.TRACK -> gain.track == 0f
@ -109,7 +101,7 @@ class ReplayGainAudioProcessor(context: Context) : BaseAudioProcessor() {
} else { } else {
// No ReplayGain tags existed, or no tags were parsable, or there was no metadata // No ReplayGain tags existed, or no tags were parsable, or there was no metadata
// in the first place. Return the gain to use when there is no ReplayGain value. // in the first place. Return the gain to use when there is no ReplayGain value.
logD("No ReplayGain tags present ") logD("No ReplayGain tags present")
preAmp.without preAmp.without
} }

View file

@ -265,6 +265,8 @@ class PlaybackService :
return return
} }
C.ENCODING_PCM_32BIT
logD("Loading ${song.rawName}") logD("Loading ${song.rawName}")
player.setMediaItem(MediaItem.fromUri(song.uri)) player.setMediaItem(MediaItem.fromUri(song.uri))
player.prepare() player.prepare()

View file

@ -140,7 +140,7 @@ class Settings(private val context: Context, private val callback: Callback? = n
get() = get() =
ReplayGainMode.fromIntCode( ReplayGainMode.fromIntCode(
inner.getInt(context.getString(R.string.set_key_replay_gain), Int.MIN_VALUE)) inner.getInt(context.getString(R.string.set_key_replay_gain), Int.MIN_VALUE))
?: ReplayGainMode.OFF ?: ReplayGainMode.DYNAMIC
/** The current ReplayGain pre-amp configuration */ /** The current ReplayGain pre-amp configuration */
var replayGainPreAmp: ReplayGainPreAmp var replayGainPreAmp: ReplayGainPreAmp

View file

@ -107,14 +107,12 @@
</integer-array> </integer-array>
<string-array name="entries_replay_gain"> <string-array name="entries_replay_gain">
<item>@string/set_replay_gain_off</item>
<item>@string/set_replay_gain_track</item> <item>@string/set_replay_gain_track</item>
<item>@string/set_replay_gain_album</item> <item>@string/set_replay_gain_album</item>
<item>@string/set_replay_gain_dynamic</item> <item>@string/set_replay_gain_dynamic</item>
</string-array> </string-array>
<integer-array name="values_replay_gain"> <integer-array name="values_replay_gain">
<item>@integer/replay_gain_off</item>
<item>@integer/replay_gain_track</item> <item>@integer/replay_gain_track</item>
<item>@integer/replay_gain_album</item> <item>@integer/replay_gain_album</item>
<item>@integer/replay_gain_dynamic</item> <item>@integer/replay_gain_dynamic</item>
@ -134,7 +132,6 @@
<integer name="play_mode_album">0xA105</integer> <integer name="play_mode_album">0xA105</integer>
<integer name="play_mode_songs">0xA106</integer> <integer name="play_mode_songs">0xA106</integer>
<integer name="replay_gain_off">0xA110</integer>
<integer name="replay_gain_track">0xA111</integer> <integer name="replay_gain_track">0xA111</integer>
<integer name="replay_gain_album">0xA112</integer> <integer name="replay_gain_album">0xA112</integer>
<integer name="replay_gain_dynamic">0xA113</integer> <integer name="replay_gain_dynamic">0xA113</integer>

View file

@ -181,7 +181,7 @@
<string name="set_audio">Audio</string> <string name="set_audio">Audio</string>
<string name="set_headset_autoplay">Headset autoplay</string> <string name="set_headset_autoplay">Headset autoplay</string>
<string name="set_headset_autoplay_desc">Always start playing when a headset is connected (may not work on all devices)</string> <string name="set_headset_autoplay_desc">Always start playing when a headset is connected (may not work on all devices)</string>
<string name="set_replay_gain">ReplayGain</string> <string name="set_replay_gain">ReplayGain strategy</string>
<string name="set_replay_gain_off">Off</string> <string name="set_replay_gain_off">Off</string>
<string name="set_replay_gain_track">Prefer track</string> <string name="set_replay_gain_track">Prefer track</string>
<string name="set_replay_gain_album">Prefer album</string> <string name="set_replay_gain_album">Prefer album</string>

View file

@ -75,15 +75,13 @@
app:title="@string/set_headset_autoplay" /> app:title="@string/set_headset_autoplay" />
<org.oxycblt.auxio.settings.ui.IntListPreference <org.oxycblt.auxio.settings.ui.IntListPreference
app:defaultValue="@integer/replay_gain_off" app:defaultValue="@integer/replay_gain_dynamic"
app:entries="@array/entries_replay_gain" app:entries="@array/entries_replay_gain"
app:entryValues="@array/values_replay_gain" app:entryValues="@array/values_replay_gain"
app:key="@string/set_key_replay_gain" app:key="@string/set_key_replay_gain"
app:offValue="@integer/replay_gain_off"
app:title="@string/set_replay_gain" /> app:title="@string/set_replay_gain" />
<org.oxycblt.auxio.settings.ui.WrappedDialogPreference <org.oxycblt.auxio.settings.ui.WrappedDialogPreference
app:dependency="@string/set_key_replay_gain"
app:key="@string/set_key_pre_amp" app:key="@string/set_key_pre_amp"
app:summary="@string/set_pre_amp_desc" app:summary="@string/set_pre_amp_desc"
app:title="@string/set_pre_amp" /> app:title="@string/set_pre_amp" />