summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2005-09-24 15:22:48 +0000
committerMagnus Holmgren <magnushol@gmail.com>2005-09-24 15:22:48 +0000
commit4b711c2f72608441f1ef44db584eccc9ca823ea1 (patch)
tree34398d7fd8f1a200c36470659b278819553c676f /apps
parent9a625ef7ac544976f45734d62294a52ef32cfe66 (diff)
downloadrockbox-4b711c2f72608441f1ef44db584eccc9ca823ea1.zip
rockbox-4b711c2f72608441f1ef44db584eccc9ca823ea1.tar.gz
rockbox-4b711c2f72608441f1ef44db584eccc9ca823ea1.tar.bz2
rockbox-4b711c2f72608441f1ef44db584eccc9ca823ea1.tar.xz
Iriver: Added new ReplayGain type: track gain if shuffle mode is active, album gain otherwise. Properly apply ReplayGain settings on config file load. Bumped config version, so save your settings.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7558 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/dsp.c14
-rw-r--r--apps/lang/english.lang6
-rw-r--r--apps/screens.c5
-rw-r--r--apps/settings.c7
-rw-r--r--apps/settings.h6
-rw-r--r--apps/settings_menu.c14
6 files changed, 38 insertions, 14 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index 23b7ea5..8ec36c3 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -708,11 +708,16 @@ void dsp_set_replaygain(bool always)
if (global_settings.replaygain || global_settings.replaygain_noclip)
{
- long peak;
+ bool track_mode
+ = ((global_settings.replaygain_type == REPLAYGAIN_TRACK)
+ || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE)
+ && global_settings.playlist_shuffle));
+ long peak = (track_mode || !dsp->album_peak)
+ ? dsp->track_peak : dsp->album_peak;
if (global_settings.replaygain)
{
- gain = (global_settings.replaygain_track || !dsp->album_gain)
+ gain = (track_mode || !dsp->album_gain)
? dsp->track_gain : dsp->album_gain;
if (global_settings.replaygain_preamp)
@@ -720,13 +725,10 @@ void dsp_set_replaygain(bool always)
long preamp = get_replaygain_int(
global_settings.replaygain_preamp * 10);
- gain = (long) ((((int64_t) gain * preamp)) >> 24);
+ gain = (long) (((int64_t) gain * preamp) >> 24);
}
}
- peak = (global_settings.replaygain_track || !dsp->album_peak)
- ? dsp->track_peak : dsp->album_peak;
-
if (gain == 0)
{
/* So that noclip can work even with no gain information. */
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 6feac25..1c27cb8 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -3292,3 +3292,9 @@ desc: repeat one song
eng: "A-B"
voice: "A-B"
new:
+
+id: LANG_SHUFFLE_GAIN
+desc: use track gain if shuffle mode is on, album gain otherwise
+eng: "Track gain if shuffling"
+voice: "Track gain if shuffling"
+new:
diff --git a/apps/screens.c b/apps/screens.c
index b28432d..b85d79b 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -53,6 +53,9 @@
#ifdef HAVE_MMC
#include "ata_mmc.h"
#endif
+#if CONFIG_CODEC == SWCODEC
+#include "dsp.h"
+#endif
#ifdef HAVE_LCD_BITMAP
#define SCROLLBAR_WIDTH 6
@@ -661,6 +664,8 @@ bool quick_screen(int context, int button)
if(audio_status() & AUDIO_STATUS_PLAY)
{
+ dsp_set_replaygain(true);
+
if (global_settings.playlist_shuffle)
playlist_randomise(NULL, current_tick, true);
else
diff --git a/apps/settings.c b/apps/settings.c
index dcb59d0..5495ca7 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -77,9 +77,10 @@ const char rec_base_directory[] = REC_BASE_DIR;
#if CONFIG_CODEC == SWCODEC
#include "pcmbuf.h"
#include "pcm_playback.h"
+#include "dsp.h"
#endif
-#define CONFIG_BLOCK_VERSION 27
+#define CONFIG_BLOCK_VERSION 28
#define CONFIG_BLOCK_SIZE 512
#define RTC_BLOCK_SIZE 44
@@ -432,7 +433,8 @@ static const struct bit_entry hd_bits[] =
#if CONFIG_CODEC == SWCODEC
{2, S_O(crossfade), 0, "crossfade type", "off,crossfade,mix"},
{1, S_O(replaygain), false, "replaygain", off_on },
- {1, S_O(replaygain_track), false, "replaygain type", "track,album" },
+ {2, S_O(replaygain_type), REPLAYGAIN_ALBUM, "replaygain type",
+ "track,album,track shuffle" },
{1, S_O(replaygain_noclip), false, "replaygain noclip", off_on },
{8 | SIGNED, S_O(replaygain_preamp), 0, "replaygain preamp", NULL },
{2, S_O(beep), 0, "off,weak,moderate,strong", NULL },
@@ -879,6 +881,7 @@ void settings_apply(void)
#if CONFIG_CODEC == SWCODEC
audio_set_crossfade(global_settings.crossfade);
+ dsp_set_replaygain(true);
#endif
#ifdef HAVE_SPDIF_POWER
diff --git a/apps/settings.h b/apps/settings.h
index 327b79a..dafa7bc 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -333,8 +333,9 @@ struct user_settings
#if CONFIG_CODEC == SWCODEC
bool replaygain; /* enable replaygain */
- bool replaygain_track; /* true for track gain, false for album gain */
bool replaygain_noclip; /* scale to prevent clips */
+ int replaygain_type; /* 0=track gain, 1=album gain, 2=track gain if
+ shuffle is on, album gain otherwise */
int replaygain_preamp; /* scale replaygained tracks by this */
int beep; /* system beep volume when changing tracks etc. */
#endif
@@ -427,4 +428,7 @@ enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, SHOW_ID3DB,
/* recursive dir insert options */
enum { RECURSE_OFF, RECURSE_ON, RECURSE_ASK };
+/* replaygain types */
+enum { REPLAYGAIN_TRACK = 0, REPLAYGAIN_ALBUM, REPLAYGAIN_SHUFFLE };
+
#endif /* __SETTINGS_H__ */
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 1bbb09d..59c8005 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -1184,11 +1184,13 @@ static bool replaygain(void)
static bool replaygain_mode(void)
{
- bool result = set_bool_options(str(LANG_REPLAYGAIN_MODE),
- &global_settings.replaygain_track,
- STR(LANG_TRACK_GAIN),
- STR(LANG_ALBUM_GAIN),
- NULL);
+ static const struct opt_items names[] = {
+ { STR(LANG_TRACK_GAIN) },
+ { STR(LANG_ALBUM_GAIN) },
+ { STR(LANG_SHUFFLE_GAIN) },
+ };
+ bool result = set_option(str(LANG_REPLAYGAIN_MODE),
+ &global_settings.replaygain_type, INT, names, 3, NULL);
dsp_set_replaygain(true);
return result;
@@ -1294,6 +1296,8 @@ static bool playback_settings_menu(void)
if ((old_shuffle != global_settings.playlist_shuffle)
&& (audio_status() & AUDIO_STATUS_PLAY))
{
+ dsp_set_replaygain(true);
+
if (global_settings.playlist_shuffle)
{
playlist_randomise(NULL, current_tick, true);