Skip to content

Commit

Permalink
detail: add replaygain values to song properties
Browse files Browse the repository at this point in the history
This should allow for clearer debugging.
  • Loading branch information
OxygenCobalt committed Jan 7, 2024
1 parent 5c85001 commit 2af90c2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.oxycblt.auxio.music.info.Name
import org.oxycblt.auxio.music.metadata.AudioProperties
import org.oxycblt.auxio.music.resolveNames
import org.oxycblt.auxio.playback.formatDurationMs
import org.oxycblt.auxio.playback.replaygain.formatDb
import org.oxycblt.auxio.ui.ViewBindingMaterialDialogFragment
import org.oxycblt.auxio.util.collectImmediately
import org.oxycblt.auxio.util.concatLocalized
Expand Down Expand Up @@ -118,6 +119,12 @@ class SongDetailDialog : ViewBindingMaterialDialogFragment<DialogSongDetailBindi
SongProperty(
R.string.lbl_sample_rate, getString(R.string.fmt_sample_rate, it)))
}
song.replayGainAdjustment.track?.let {
add(SongProperty(R.string.lbl_replaygain_track, it.formatDb(context)))
}
song.replayGainAdjustment.album?.let {
add(SongProperty(R.string.lbl_replaygain_album, it.formatDb(context)))
}
},
UpdateInstructions.Replace(0))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import kotlin.math.abs
import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.DialogPreAmpBinding
import org.oxycblt.auxio.playback.PlaybackSettings
Expand Down Expand Up @@ -85,11 +84,6 @@ class PreAmpCustomizeDialog : ViewBindingMaterialDialogFragment<DialogPreAmpBind
// It is more clear to prepend a +/- before the pre-amp value to make it easier to
// gauge how much it may be increasing the volume, however android does not add +
// to positive float values when formatting them in a string. Instead, add it ourselves.
ticker.text =
if (valueDb >= 0) {
getString(R.string.fmt_db_pos, valueDb)
} else {
getString(R.string.fmt_db_neg, abs(valueDb))
}
ticker.text = valueDb.formatDb(requireContext())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

package org.oxycblt.auxio.playback.replaygain

import android.content.Context
import kotlin.math.abs
import org.oxycblt.auxio.IntegerTable
import org.oxycblt.auxio.R

/**
* The current ReplayGain configuration.
Expand Down Expand Up @@ -67,3 +70,16 @@ data class ReplayGainAdjustment(val track: Float?, val album: Float?)
* @author Alexander Capehart (OxygenCobalt)
*/
data class ReplayGainPreAmp(val with: Float, val without: Float)

/**
* Format a decibel value in a human-readable format.
*
* @param context The context to resolve resources from.
* @return A formatted decibel value. Will be prefixed by a + or - sign.
*/
fun Float.formatDb(context: Context) =
if (this >= 0) {
context.getString(R.string.fmt_db_pos, this)
} else {
context.getString(R.string.fmt_db_neg, abs(this))
}
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@
<string name="lbl_size">Size</string>
<string name="lbl_bitrate">Bit rate</string>
<string name="lbl_sample_rate">Sample rate</string>
<string name="lbl_replaygain_track">ReplayGain Track Adjustment</string>
<string name="lbl_replaygain_album">ReplayGain Album Adjustment</string>

<!-- Limit to 10 characters -->
<string name="lbl_shuffle_shortcut_short">Shuffle</string>
Expand Down

0 comments on commit 2af90c2

Please sign in to comment.