summaryrefslogtreecommitdiff
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
parent9a625ef7ac544976f45734d62294a52ef32cfe66 (diff)
downloadrockbox-4b711c2f72608441f1ef44db584eccc9ca823ea1.tar.gz
rockbox-4b711c2f72608441f1ef44db584eccc9ca823ea1.zip
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
-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 23b7ea548d..8ec36c3f33 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -708,11 +708,16 @@ void dsp_set_replaygain(bool always)
708 708
709 if (global_settings.replaygain || global_settings.replaygain_noclip) 709 if (global_settings.replaygain || global_settings.replaygain_noclip)
710 { 710 {
711 long peak; 711 bool track_mode
712 = ((global_settings.replaygain_type == REPLAYGAIN_TRACK)
713 || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE)
714 && global_settings.playlist_shuffle));
715 long peak = (track_mode || !dsp->album_peak)
716 ? dsp->track_peak : dsp->album_peak;
712 717
713 if (global_settings.replaygain) 718 if (global_settings.replaygain)
714 { 719 {
715 gain = (global_settings.replaygain_track || !dsp->album_gain) 720 gain = (track_mode || !dsp->album_gain)
716 ? dsp->track_gain : dsp->album_gain; 721 ? dsp->track_gain : dsp->album_gain;
717 722
718 if (global_settings.replaygain_preamp) 723 if (global_settings.replaygain_preamp)
@@ -720,13 +725,10 @@ void dsp_set_replaygain(bool always)
720 long preamp = get_replaygain_int( 725 long preamp = get_replaygain_int(
721 global_settings.replaygain_preamp * 10); 726 global_settings.replaygain_preamp * 10);
722 727
723 gain = (long) ((((int64_t) gain * preamp)) >> 24); 728 gain = (long) (((int64_t) gain * preamp) >> 24);
724 } 729 }
725 } 730 }
726 731
727 peak = (global_settings.replaygain_track || !dsp->album_peak)
728 ? dsp->track_peak : dsp->album_peak;
729
730 if (gain == 0) 732 if (gain == 0)
731 { 733 {
732 /* So that noclip can work even with no gain information. */ 734 /* So that noclip can work even with no gain information. */
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 6feac25ee8..1c27cb8df1 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -3292,3 +3292,9 @@ desc: repeat one song
3292eng: "A-B" 3292eng: "A-B"
3293voice: "A-B" 3293voice: "A-B"
3294new: 3294new:
3295
3296id: LANG_SHUFFLE_GAIN
3297desc: use track gain if shuffle mode is on, album gain otherwise
3298eng: "Track gain if shuffling"
3299voice: "Track gain if shuffling"
3300new:
diff --git a/apps/screens.c b/apps/screens.c
index b28432d1fd..b85d79bb28 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -53,6 +53,9 @@
53#ifdef HAVE_MMC 53#ifdef HAVE_MMC
54#include "ata_mmc.h" 54#include "ata_mmc.h"
55#endif 55#endif
56#if CONFIG_CODEC == SWCODEC
57#include "dsp.h"
58#endif
56 59
57#ifdef HAVE_LCD_BITMAP 60#ifdef HAVE_LCD_BITMAP
58#define SCROLLBAR_WIDTH 6 61#define SCROLLBAR_WIDTH 6
@@ -661,6 +664,8 @@ bool quick_screen(int context, int button)
661 664
662 if(audio_status() & AUDIO_STATUS_PLAY) 665 if(audio_status() & AUDIO_STATUS_PLAY)
663 { 666 {
667 dsp_set_replaygain(true);
668
664 if (global_settings.playlist_shuffle) 669 if (global_settings.playlist_shuffle)
665 playlist_randomise(NULL, current_tick, true); 670 playlist_randomise(NULL, current_tick, true);
666 else 671 else
diff --git a/apps/settings.c b/apps/settings.c
index dcb59d08b6..5495ca7098 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -77,9 +77,10 @@ const char rec_base_directory[] = REC_BASE_DIR;
77#if CONFIG_CODEC == SWCODEC 77#if CONFIG_CODEC == SWCODEC
78#include "pcmbuf.h" 78#include "pcmbuf.h"
79#include "pcm_playback.h" 79#include "pcm_playback.h"
80#include "dsp.h"
80#endif 81#endif
81 82
82#define CONFIG_BLOCK_VERSION 27 83#define CONFIG_BLOCK_VERSION 28
83#define CONFIG_BLOCK_SIZE 512 84#define CONFIG_BLOCK_SIZE 512
84#define RTC_BLOCK_SIZE 44 85#define RTC_BLOCK_SIZE 44
85 86
@@ -432,7 +433,8 @@ static const struct bit_entry hd_bits[] =
432#if CONFIG_CODEC == SWCODEC 433#if CONFIG_CODEC == SWCODEC
433 {2, S_O(crossfade), 0, "crossfade type", "off,crossfade,mix"}, 434 {2, S_O(crossfade), 0, "crossfade type", "off,crossfade,mix"},
434 {1, S_O(replaygain), false, "replaygain", off_on }, 435 {1, S_O(replaygain), false, "replaygain", off_on },
435 {1, S_O(replaygain_track), false, "replaygain type", "track,album" }, 436 {2, S_O(replaygain_type), REPLAYGAIN_ALBUM, "replaygain type",
437 "track,album,track shuffle" },
436 {1, S_O(replaygain_noclip), false, "replaygain noclip", off_on }, 438 {1, S_O(replaygain_noclip), false, "replaygain noclip", off_on },
437 {8 | SIGNED, S_O(replaygain_preamp), 0, "replaygain preamp", NULL }, 439 {8 | SIGNED, S_O(replaygain_preamp), 0, "replaygain preamp", NULL },
438 {2, S_O(beep), 0, "off,weak,moderate,strong", NULL }, 440 {2, S_O(beep), 0, "off,weak,moderate,strong", NULL },
@@ -879,6 +881,7 @@ void settings_apply(void)
879 881
880#if CONFIG_CODEC == SWCODEC 882#if CONFIG_CODEC == SWCODEC
881 audio_set_crossfade(global_settings.crossfade); 883 audio_set_crossfade(global_settings.crossfade);
884 dsp_set_replaygain(true);
882#endif 885#endif
883 886
884#ifdef HAVE_SPDIF_POWER 887#ifdef HAVE_SPDIF_POWER
diff --git a/apps/settings.h b/apps/settings.h
index 327b79a7ee..dafa7bcd34 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -333,8 +333,9 @@ struct user_settings
333 333
334#if CONFIG_CODEC == SWCODEC 334#if CONFIG_CODEC == SWCODEC
335 bool replaygain; /* enable replaygain */ 335 bool replaygain; /* enable replaygain */
336 bool replaygain_track; /* true for track gain, false for album gain */
337 bool replaygain_noclip; /* scale to prevent clips */ 336 bool replaygain_noclip; /* scale to prevent clips */
337 int replaygain_type; /* 0=track gain, 1=album gain, 2=track gain if
338 shuffle is on, album gain otherwise */
338 int replaygain_preamp; /* scale replaygained tracks by this */ 339 int replaygain_preamp; /* scale replaygained tracks by this */
339 int beep; /* system beep volume when changing tracks etc. */ 340 int beep; /* system beep volume when changing tracks etc. */
340#endif 341#endif
@@ -427,4 +428,7 @@ enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, SHOW_ID3DB,
427/* recursive dir insert options */ 428/* recursive dir insert options */
428enum { RECURSE_OFF, RECURSE_ON, RECURSE_ASK }; 429enum { RECURSE_OFF, RECURSE_ON, RECURSE_ASK };
429 430
431/* replaygain types */
432enum { REPLAYGAIN_TRACK = 0, REPLAYGAIN_ALBUM, REPLAYGAIN_SHUFFLE };
433
430#endif /* __SETTINGS_H__ */ 434#endif /* __SETTINGS_H__ */
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 1bbb09d8b0..59c800588f 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -1184,11 +1184,13 @@ static bool replaygain(void)
1184 1184
1185static bool replaygain_mode(void) 1185static bool replaygain_mode(void)
1186{ 1186{
1187 bool result = set_bool_options(str(LANG_REPLAYGAIN_MODE), 1187 static const struct opt_items names[] = {
1188 &global_settings.replaygain_track, 1188 { STR(LANG_TRACK_GAIN) },
1189 STR(LANG_TRACK_GAIN), 1189 { STR(LANG_ALBUM_GAIN) },
1190 STR(LANG_ALBUM_GAIN), 1190 { STR(LANG_SHUFFLE_GAIN) },
1191 NULL); 1191 };
1192 bool result = set_option(str(LANG_REPLAYGAIN_MODE),
1193 &global_settings.replaygain_type, INT, names, 3, NULL);
1192 1194
1193 dsp_set_replaygain(true); 1195 dsp_set_replaygain(true);
1194 return result; 1196 return result;
@@ -1294,6 +1296,8 @@ static bool playback_settings_menu(void)
1294 if ((old_shuffle != global_settings.playlist_shuffle) 1296 if ((old_shuffle != global_settings.playlist_shuffle)
1295 && (audio_status() & AUDIO_STATUS_PLAY)) 1297 && (audio_status() & AUDIO_STATUS_PLAY))
1296 { 1298 {
1299 dsp_set_replaygain(true);
1300
1297 if (global_settings.playlist_shuffle) 1301 if (global_settings.playlist_shuffle)
1298 { 1302 {
1299 playlist_randomise(NULL, current_tick, true); 1303 playlist_randomise(NULL, current_tick, true);