summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2006-02-04 23:15:15 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2006-02-04 23:15:15 +0000
commit621bcc22940aed0242ed1795491a400521d2394d (patch)
tree4e2436a360db85c5b2cbe82b71a525e682b37738
parent2fcd1b09d4514856153dee14f55ba5bbd10d43a8 (diff)
downloadrockbox-621bcc22940aed0242ed1795491a400521d2394d.tar.gz
rockbox-621bcc22940aed0242ed1795491a400521d2394d.zip
The simulator should use the keypad period key, not the regular one
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8568 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/SOURCES1
-rw-r--r--apps/dsp.c58
-rw-r--r--apps/dsp.h1
-rw-r--r--apps/eq.c8
-rw-r--r--apps/lang/english.lang54
-rw-r--r--apps/settings.c22
-rw-r--r--apps/settings.h34
-rw-r--r--apps/sound_menu.c2
-rwxr-xr-xtools/buildzip.pl1
-rw-r--r--uisimulator/sdl/button.c2
10 files changed, 176 insertions, 7 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index 35f78c455e..ef65789588 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -78,4 +78,5 @@ eq_cf.S
78#elif defined(CPU_ARM) && !defined(SIMULATOR) 78#elif defined(CPU_ARM) && !defined(SIMULATOR)
79eq_arm.S 79eq_arm.S
80#endif 80#endif
81eq_menu.c
81#endif 82#endif
diff --git a/apps/dsp.c b/apps/dsp.c
index 789cf72b20..f403674ba2 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -145,6 +145,7 @@ struct dsp_config
145 bool dither_enabled; 145 bool dither_enabled;
146 bool new_gain; 146 bool new_gain;
147 bool crossfeed_enabled; 147 bool crossfeed_enabled;
148 bool eq_enabled;
148}; 149};
149 150
150struct resample_data 151struct resample_data
@@ -618,6 +619,52 @@ static void apply_crossfeed(long* src[], int count)
618} 619}
619#endif 620#endif
620 621
622#define EQ_CUTOFF_USER2REAL(x) (0xffffffff / dsp->frequency * (x))
623#define EQ_Q_USER2REAL(x) (((x) << 16) / 10)
624#define EQ_GAIN_USER2REAL(x) (((x) << 16) / 10)
625
626/* Synchronize the EQ filters with the global settings */
627static void eq_update_data()
628{
629 int i;
630 int *setting;
631 int gain, cutoff, q, maxgain;
632
633 /* Don't do anything if we're not playing */
634 if (dsp->frequency == 0)
635 return;
636
637 setting = &global_settings.eq_band0_cutoff;
638 maxgain = 0;
639
640 /* Iterate over each band and update the appropriate filter */
641 for(i = 0; i < 5; i++) {
642 cutoff = *setting++;
643 q = *setting++;
644 gain = *setting++;
645
646 /* Keep track of maxgain for the pre-amp */
647 if (gain > maxgain)
648 maxgain = gain;
649
650 if (gain == 0) {
651 eq_data.enabled[i] = 0;
652 } else {
653 if (i == 0)
654 eq_ls_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
655 EQ_GAIN_USER2REAL(gain), eq_data.filters[0].coefs);
656 else if (i == 4)
657 eq_hs_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
658 EQ_GAIN_USER2REAL(gain), eq_data.filters[4].coefs);
659 else
660 eq_pk_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
661 EQ_GAIN_USER2REAL(gain), eq_data.filters[i].coefs);
662
663 eq_data.enabled[i] = 1;
664 }
665 }
666}
667
621/* Apply EQ filters to those bands that have got it switched on. */ 668/* Apply EQ filters to those bands that have got it switched on. */
622static void eq_process(long **x, unsigned num) 669static void eq_process(long **x, unsigned num)
623{ 670{
@@ -737,6 +784,9 @@ long dsp_process(char* dst, char* src[], long size)
737 size /= dsp->sample_bytes * factor; 784 size /= dsp->sample_bytes * factor;
738 dsp_set_replaygain(false); 785 dsp_set_replaygain(false);
739 786
787 if (dsp->eq_enabled)
788 eq_update_data();
789
740 while (size > 0) 790 while (size > 0)
741 { 791 {
742 samples = convert_to_internal(src, size, tmp); 792 samples = convert_to_internal(src, size, tmp);
@@ -745,8 +795,7 @@ long dsp_process(char* dst, char* src[], long size)
745 samples = resample(tmp, samples); 795 samples = resample(tmp, samples);
746 if (dsp->crossfeed_enabled && dsp->stereo_mode != STEREO_MONO) 796 if (dsp->crossfeed_enabled && dsp->stereo_mode != STEREO_MONO)
747 apply_crossfeed(tmp, samples); 797 apply_crossfeed(tmp, samples);
748 /* TODO: Might want to wrap this with a generic eq_enabled when the 798 if (dsp->eq_enabled)
749 settings are in place */
750 eq_process(tmp, samples); 799 eq_process(tmp, samples);
751 write_samples((short*) dst, tmp, samples); 800 write_samples((short*) dst, tmp, samples);
752 written += samples; 801 written += samples;
@@ -943,6 +992,11 @@ bool dsp_configure(int setting, void *value)
943 return 1; 992 return 1;
944} 993}
945 994
995void dsp_set_eq(bool enable)
996{
997 dsp->eq_enabled = enable;
998}
999
946void dsp_set_crossfeed(bool enable) 1000void dsp_set_crossfeed(bool enable)
947{ 1001{
948 if (enable) 1002 if (enable)
diff --git a/apps/dsp.h b/apps/dsp.h
index f86a4d9989..11b20b1866 100644
--- a/apps/dsp.h
+++ b/apps/dsp.h
@@ -54,6 +54,7 @@ int dsp_stereo_mode(void);
54bool dsp_configure(int setting, void *value); 54bool dsp_configure(int setting, void *value);
55void dsp_set_replaygain(bool always); 55void dsp_set_replaygain(bool always);
56void dsp_set_crossfeed(bool enable); 56void dsp_set_crossfeed(bool enable);
57void dsp_set_eq(bool enable);
57void sound_set_pitch(int r); 58void sound_set_pitch(int r);
58int sound_get_pitch(void); 59int sound_get_pitch(void);
59#endif 60#endif
diff --git a/apps/eq.c b/apps/eq.c
index 17165be541..7921028403 100644
--- a/apps/eq.c
+++ b/apps/eq.c
@@ -32,11 +32,11 @@
32 */ 32 */
33 33
34#define DIV64(x, y, z) (long)(((long long)(x) << (z))/(y)) 34#define DIV64(x, y, z) (long)(((long long)(x) << (z))/(y))
35/* TODO: This macro requires the EMAC unit to be in fractional mode 35/* This macro requires the EMAC unit to be in fractional mode
36 when the coef generator routines are called. If this can be guaranteeed, 36 when the coef generator routines are called. If this can't be guaranteeed,
37 then remove the "&& 0" below for faster coef calculation on Coldfire. 37 then add "&& 0" below. This will use a slower coef calculation on Coldfire.
38 */ 38 */
39#if defined(CPU_COLDFIRE) && !defined(SIMULATOR) && 0 39#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
40#define FRACMUL(x, y) \ 40#define FRACMUL(x, y) \
41({ \ 41({ \
42 long t; \ 42 long t; \
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index a2803ad432..f024d645fe 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -3599,3 +3599,57 @@ eng: "Backdrop failed"
3599voice: "Backdrop failed" 3599voice: "Backdrop failed"
3600new: 3600new:
3601 3601
3602id: LANG_EQUALIZER
3603desc: in the sound settings menu
3604eng: "Equalizer"
3605voice: "Equalizer"
3606new:
3607
3608id: LANG_EQUALIZER_SETTINGS
3609desc: in the equalizer menu
3610eng: "Browse EQ Presets"
3611voice: "Browse EQ Presets"
3612new:
3613
3614id: LANG_EQUALIZER_GRAPHICAL
3615desc: in the equalizer menu
3616eng: "Graphical EQ"
3617voice: "Graphical EQ"
3618new:
3619
3620id: LANG_EQUALIZER_GAIN
3621desc: in the equalizer menu
3622eng: "EQ Gain"
3623voice: "EQ Gain"
3624new:
3625
3626id: LANG_EQUALIZER_GAIN_ITEM
3627desc: in the equalizer menu
3628eng: "%d Hz Band Gain"
3629voice: ""
3630new:
3631
3632id: LANG_EQUALIZER_ADVANCED
3633desc: in the equalizer menu
3634eng: "EQ Advanced Settings"
3635voice: "EQ Advanced Settings"
3636new:
3637
3638id: LANG_EQUALIZER_BAND_CUTOFF
3639desc: in the equalizer menu
3640eng: "Cutoff"
3641voice: "Cutoff"
3642new:
3643
3644id: LANG_EQUALIZER_BAND_Q
3645desc: in the equalizer menu
3646eng: "Q"
3647voice: "Q"
3648new:
3649
3650id: LANG_EQUALIZER_BAND_GAIN
3651desc: in the equalizer menu
3652eng: "Gain"
3653voice: "Gain"
3654new:
3655
diff --git a/apps/settings.c b/apps/settings.c
index 07db21ef66..fd1b530890 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -508,6 +508,28 @@ static const struct bit_entry hd_bits[] =
508#endif 508#endif
509#endif /* HAVE_LCD_BITMAP */ 509#endif /* HAVE_LCD_BITMAP */
510 510
511#if CONFIG_CODEC == SWCODEC
512 {1, S_O(eq_enabled), false, "eq enabled", off_on },
513 /* 0..32768 Hz */
514 {15, S_O(eq_band0_cutoff), 60, "eq band 0 cutoff", NULL },
515 {15, S_O(eq_band1_cutoff), 200, "eq band 1 cutoff", NULL },
516 {15, S_O(eq_band2_cutoff), 800, "eq band 2 cutoff", NULL },
517 {15, S_O(eq_band3_cutoff), 4000, "eq band 3 cutoff", NULL },
518 {15, S_O(eq_band4_cutoff), 12000, "eq band 4 cutoff", NULL },
519 /* 0..64 (or 0.0 to 6.4) */
520 {6, S_O(eq_band0_q), 7, "eq band 0 q", NULL },
521 {6, S_O(eq_band1_q), 10, "eq band 1 q", NULL },
522 {6, S_O(eq_band2_q), 10, "eq band 2 q", NULL },
523 {6, S_O(eq_band3_q), 10, "eq band 3 q", NULL },
524 {6, S_O(eq_band4_q), 7, "eq band 4 q", NULL },
525 /* -240..240 (or -24db to +24db) */
526 {9|SIGNED, S_O(eq_band0_gain), 0, "eq band 0 gain", NULL },
527 {9|SIGNED, S_O(eq_band1_gain), 0, "eq band 1 gain", NULL },
528 {9|SIGNED, S_O(eq_band2_gain), 0, "eq band 2 gain", NULL },
529 {9|SIGNED, S_O(eq_band3_gain), 0, "eq band 3 gain", NULL },
530 {9|SIGNED, S_O(eq_band4_gain), 0, "eq band 4 gain", NULL },
531#endif
532
511 /* If values are just added to the end, no need to bump the version. */ 533 /* If values are just added to the end, no need to bump the version. */
512 /* new stuff to be added at the end */ 534 /* new stuff to be added at the end */
513 535
diff --git a/apps/settings.h b/apps/settings.h
index bb58336202..bb401b674e 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -39,6 +39,7 @@
39#define PLUGIN_DIR ROCKBOX_DIR"/rocks" 39#define PLUGIN_DIR ROCKBOX_DIR"/rocks"
40#define BACKDROP_DIR ROCKBOX_DIR"/backdrops" 40#define BACKDROP_DIR ROCKBOX_DIR"/backdrops"
41#define REC_BASE_DIR "/recordings" 41#define REC_BASE_DIR "/recordings"
42#define EQS_DIR ROCKBOX_DIR "/eqs"
42 43
43#define MAX_FILENAME 20 44#define MAX_FILENAME 20
44 45
@@ -408,6 +409,39 @@ struct user_settings
408 int brightness; /* iriver h300: backlight PWM value: 2..15 409 int brightness; /* iriver h300: backlight PWM value: 2..15
409 (0 and 1 are black) */ 410 (0 and 1 are black) */
410#endif 411#endif
412
413#if CONFIG_CODEC == SWCODEC
414 bool eq_enabled; /* Enable equalizer */
415
416 /* Order is important here, must be cutoff, q, then gain for each band.
417 See dsp_eq_update_data in dsp.c for why. */
418
419 /* Band 0 settings */
420 int eq_band0_cutoff; /* Hz */
421 int eq_band0_q;
422 int eq_band0_gain; /* +/- dB */
423
424 /* Band 1 settings */
425 int eq_band1_cutoff; /* Hz */
426 int eq_band1_q;
427 int eq_band1_gain; /* +/- dB */
428
429 /* Band 2 settings */
430 int eq_band2_cutoff; /* Hz */
431 int eq_band2_q;
432 int eq_band2_gain; /* +/- dB */
433
434 /* Band 3 settings */
435 int eq_band3_cutoff; /* Hz */
436 int eq_band3_q;
437 int eq_band3_gain; /* +/- dB */
438
439 /* Band 4 settings */
440 int eq_band4_cutoff; /* Hz */
441 int eq_band4_q;
442 int eq_band4_gain; /* +/- dB */
443#endif
444
411#ifdef HAVE_LCD_COLOR 445#ifdef HAVE_LCD_COLOR
412 unsigned char backdrop_file[MAX_FILENAME+1]; /* backdrop bitmap file */ 446 unsigned char backdrop_file[MAX_FILENAME+1]; /* backdrop bitmap file */
413#endif 447#endif
diff --git a/apps/sound_menu.c b/apps/sound_menu.c
index e44aa68231..2bd0ff6e59 100644
--- a/apps/sound_menu.c
+++ b/apps/sound_menu.c
@@ -45,6 +45,7 @@
45#include "splash.h" 45#include "splash.h"
46#if CONFIG_CODEC == SWCODEC 46#if CONFIG_CODEC == SWCODEC
47#include "dsp.h" 47#include "dsp.h"
48#include "eq_menu.h"
48#endif 49#endif
49 50
50int selected_setting; /* Used by the callback */ 51int selected_setting; /* Used by the callback */
@@ -379,6 +380,7 @@ bool sound_menu(void)
379 { ID2P(LANG_STEREO_WIDTH), stereo_width }, 380 { ID2P(LANG_STEREO_WIDTH), stereo_width },
380#if CONFIG_CODEC == SWCODEC 381#if CONFIG_CODEC == SWCODEC
381 { ID2P(LANG_CROSSFEED), crossfeed }, 382 { ID2P(LANG_CROSSFEED), crossfeed },
383 { ID2P(LANG_EQUALIZER), eq_menu },
382#endif 384#endif
383#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) 385#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
384 { ID2P(LANG_LOUDNESS), loudness }, 386 { ID2P(LANG_LOUDNESS), loudness },
diff --git a/tools/buildzip.pl b/tools/buildzip.pl
index a9af7619db..fad73624ed 100755
--- a/tools/buildzip.pl
+++ b/tools/buildzip.pl
@@ -91,6 +91,7 @@ sub buildzip {
91 mkdir ".rockbox/wps", 0777; 91 mkdir ".rockbox/wps", 0777;
92 mkdir ".rockbox/themes", 0777; 92 mkdir ".rockbox/themes", 0777;
93 mkdir ".rockbox/backdrops", 0777; 93 mkdir ".rockbox/backdrops", 0777;
94 mkdir ".rockbox/eqs", 0777;
94 95
95 my $c = 'find apps -name "*.codec" ! -empty -exec cp {} .rockbox/codecs/ \;'; 96 my $c = 'find apps -name "*.codec" ! -empty -exec cp {} .rockbox/codecs/ \;';
96 print `$c`; 97 print `$c`;
diff --git a/uisimulator/sdl/button.c b/uisimulator/sdl/button.c
index 5def88b9af..e8db43930f 100644
--- a/uisimulator/sdl/button.c
+++ b/uisimulator/sdl/button.c
@@ -135,7 +135,7 @@ void button_event(int key, bool pressed)
135 break; 135 break;
136#endif 136#endif
137 137
138 case SDLK_PERIOD: 138 case SDLK_KP_PERIOD:
139 case SDLK_INSERT: 139 case SDLK_INSERT:
140#ifdef BUTTON_MENU 140#ifdef BUTTON_MENU
141 new_btn = BUTTON_MENU; 141 new_btn = BUTTON_MENU;