aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-09-22 16:10:51 -0700
committerScott Jackson <daneren2005@gmail.com>2014-09-22 16:10:51 -0700
commit091bba2a329f236251d69697f892b923796a5e5c (patch)
tree8b61104f9ab8ecb781d23f8d4c8af3307b09353d
parent2b68dad21ad76cafdb51b1f8d50793735a54260a (diff)
downloaddsub-091bba2a329f236251d69697f892b923796a5e5c.tar.gz
dsub-091bba2a329f236251d69697f892b923796a5e5c.tar.bz2
dsub-091bba2a329f236251d69697f892b923796a5e5c.zip
Add start of smart replaygain logic, make it optional
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index ab302729..1e32bd2a 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -137,6 +137,7 @@ public class DownloadService extends Service {
private int cachedPosition = 0;
private boolean downloadOngoing = false;
private float volume = 1.0f;
+ private boolean singleAlbum = false;
private AudioEffectsController effectsController;
private RemoteControlState remoteState = RemoteControlState.LOCAL;
@@ -1939,14 +1940,17 @@ public class DownloadService extends Service {
try {
float[] rg = BastpUtil.getReplayGainValues(downloadFile.getFile().getCanonicalPath()); /* track, album */
float adjust = 0f;
- if (true /*mReplayGainAlbumEnabled*/) {
- adjust = (rg[0] != 0 ? rg[0] : adjust); /* do we have track adjustment ? */
- adjust = (rg[1] != 0 ? rg[1] : adjust); /* ..or, even better, album adj? */
- }
- if (/*mReplayGainTrackEnabled || (mReplayGainAlbumEnabled && */ adjust == 0) {
- adjust = (rg[1] != 0 ? rg[1] : adjust); /* do we have album adjustment ? */
- adjust = (rg[0] != 0 ? rg[0] : adjust); /* ..or, even better, track adj? */
+ if (Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_REPLAY_GAIN, true)) {
+ // If playing a single album or no track gain, use album gain
+ if((singleAlbum || rg[0] == 0) && rg[1] != 0) {
+ adjust = rg[1];
+ } else {
+ // Otherwise, give priority to track gain
+ adjust = rg[0];
+ }
}
+
+ // TODO: Figure out if I want any of this logic
if (adjust == 0) {
/* No RG value found: decrease volume for untagged song if requested by user */
// adjust = (mReplayGainUntaggedDeBump - 150) / 10f;
@@ -1956,10 +1960,7 @@ public class DownloadService extends Service {
** But we want -15 <-> +15, so 75 shall be zero */
// adjust += 2 * (mReplayGainBump - 75) / 10f; /* 2* -> we want +-15, not +-7.5 */
}
- /*if (mReplayGainAlbumEnabled == false && mReplayGainTrackEnabled == false) {
- // Feature is disabled: Make sure that we are going to 100% volume
- adjust = 0f;
- }*/
+
float rg_result = ((float) Math.pow(10, (adjust / 20))) * volume;
if (rg_result > 1.0f) {
rg_result = 1.0f; /* android would IGNORE the change if this is > 1 and we would end up with the wrong volume */