summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/dsp.c57
-rw-r--r--apps/dsp.h2
-rw-r--r--apps/eq_menu.c21
-rw-r--r--apps/settings.c7
4 files changed, 47 insertions, 40 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index 7ea9ecfafd..daecd5c69e 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -624,48 +624,43 @@ static void apply_crossfeed(long* src[], int count)
624#define EQ_GAIN_USER2REAL(x) (((x) << 16) / 10) 624#define EQ_GAIN_USER2REAL(x) (((x) << 16) / 10)
625 625
626/* Synchronize the EQ filters with the global settings */ 626/* Synchronize the EQ filters with the global settings */
627void dsp_eq_update_data(bool enabled) 627void dsp_eq_update_data(bool enabled, int band)
628{ 628{
629 int i;
630 int *setting; 629 int *setting;
631 int gain, cutoff, q, maxgain; 630 int gain, cutoff, q;
632 631
633 dsp->eq_enabled = enabled; 632 dsp->eq_enabled = enabled;
634 setting = &global_settings.eq_band0_cutoff;
635 maxgain = 0;
636 633
634 /* Adjust setting pointer to the band we actually want to change */
635 setting = &global_settings.eq_band0_cutoff + (band * 3);
636
637 cutoff = *setting++;
638 q = *setting++;
639 gain = *setting++;
640
641 DEBUGF("cutoff %d, q %d, gain %d\n", cutoff, q, gain);
642
637 #if defined(CPU_COLDFIRE) && !defined(SIMULATOR) 643 #if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
638 /* set emac unit for dsp processing, and save old macsr, we're running in 644 /* set emac unit for dsp processing, and save old macsr, we're running in
639 codec thread context at this point, so can't clobber it */ 645 codec thread context at this point, so can't clobber it */
640 unsigned long old_macsr = coldfire_get_macsr(); 646 unsigned long old_macsr = coldfire_get_macsr();
641 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE | EMAC_ROUND); 647 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE | EMAC_ROUND);
642 #endif 648 #endif
643
644 /* Iterate over each band and update the appropriate filter */
645 for(i = 0; i < 5; i++) {
646 cutoff = *setting++;
647 q = *setting++;
648 gain = *setting++;
649
650 /* Keep track of maxgain for the pre-amp */
651 if (gain > maxgain)
652 maxgain = gain;
653
654 if (gain == 0) {
655 eq_data.enabled[i] = 0;
656 } else {
657 if (i == 0)
658 eq_ls_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
659 EQ_GAIN_USER2REAL(gain), eq_data.filters[0].coefs);
660 else if (i == 4)
661 eq_hs_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
662 EQ_GAIN_USER2REAL(gain), eq_data.filters[4].coefs);
663 else
664 eq_pk_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
665 EQ_GAIN_USER2REAL(gain), eq_data.filters[i].coefs);
666 649
667 eq_data.enabled[i] = 1; 650 if (gain == 0) {
668 } 651 eq_data.enabled[band] = 0;
652 } else {
653 if (band == 0)
654 eq_ls_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
655 EQ_GAIN_USER2REAL(gain), eq_data.filters[band].coefs);
656 else if (band == 4)
657 eq_hs_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
658 EQ_GAIN_USER2REAL(gain), eq_data.filters[band].coefs);
659 else
660 eq_pk_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
661 EQ_GAIN_USER2REAL(gain), eq_data.filters[band].coefs);
662
663 eq_data.enabled[band] = 1;
669 } 664 }
670 665
671 #if defined(CPU_COLDFIRE) && !defined(SIMULATOR) 666 #if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
diff --git a/apps/dsp.h b/apps/dsp.h
index 7e3acacc32..c20def03b7 100644
--- a/apps/dsp.h
+++ b/apps/dsp.h
@@ -54,7 +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_eq_update_data(bool enabled); 57void dsp_eq_update_data(bool enabled, int band);
58void sound_set_pitch(int r); 58void sound_set_pitch(int r);
59int sound_get_pitch(void); 59int sound_get_pitch(void);
60#endif 60#endif
diff --git a/apps/eq_menu.c b/apps/eq_menu.c
index 73c066705c..96935ca669 100644
--- a/apps/eq_menu.c
+++ b/apps/eq_menu.c
@@ -105,10 +105,15 @@
105 105
106static bool eq_enabled(void) 106static bool eq_enabled(void)
107{ 107{
108 int i;
109
108 bool result = set_bool(str(LANG_EQUALIZER_ENABLED), 110 bool result = set_bool(str(LANG_EQUALIZER_ENABLED),
109 &global_settings.eq_enabled); 111 &global_settings.eq_enabled);
110 112
111 dsp_eq_update_data(global_settings.eq_enabled); 113 /* Update all bands */
114 for(i = 0; i < 5; i++) {
115 dsp_eq_update_data(global_settings.eq_enabled, i);
116 }
112 117
113 return result; 118 return result;
114} 119}
@@ -136,7 +141,7 @@ static bool eq_set_band ## band ## _center(void) \
136 bool result = set_int(str(LANG_EQUALIZER_BAND_CENTER), "Hertz", UNIT_HERTZ, \ 141 bool result = set_int(str(LANG_EQUALIZER_BAND_CENTER), "Hertz", UNIT_HERTZ, \
137 &global_settings.eq_band ## band ## _cutoff, NULL, \ 142 &global_settings.eq_band ## band ## _cutoff, NULL, \
138 EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \ 143 EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \
139 dsp_eq_update_data(global_settings.eq_enabled); \ 144 dsp_eq_update_data(global_settings.eq_enabled, band); \
140 return result; \ 145 return result; \
141} 146}
142 147
@@ -146,7 +151,7 @@ static bool eq_set_band ## band ## _cutoff(void) \
146 bool result = set_int(str(LANG_EQUALIZER_BAND_CUTOFF), "Hertz", UNIT_HERTZ, \ 151 bool result = set_int(str(LANG_EQUALIZER_BAND_CUTOFF), "Hertz", UNIT_HERTZ, \
147 &global_settings.eq_band ## band ## _cutoff, NULL, \ 152 &global_settings.eq_band ## band ## _cutoff, NULL, \
148 EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \ 153 EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \
149 dsp_eq_update_data(global_settings.eq_enabled); \ 154 dsp_eq_update_data(global_settings.eq_enabled, band); \
150 return result; \ 155 return result; \
151} 156}
152 157
@@ -156,7 +161,7 @@ static bool eq_set_band ## band ## _q(void) \
156 bool result = set_int(str(LANG_EQUALIZER_BAND_Q), "Q", UNIT_INT, \ 161 bool result = set_int(str(LANG_EQUALIZER_BAND_Q), "Q", UNIT_INT, \
157 &global_settings.eq_band ## band ## _q, NULL, \ 162 &global_settings.eq_band ## band ## _q, NULL, \
158 EQ_Q_STEP, EQ_Q_MIN, EQ_Q_MAX, eq_q_format); \ 163 EQ_Q_STEP, EQ_Q_MIN, EQ_Q_MAX, eq_q_format); \
159 dsp_eq_update_data(global_settings.eq_enabled); \ 164 dsp_eq_update_data(global_settings.eq_enabled, band); \
160 return result; \ 165 return result; \
161} 166}
162 167
@@ -166,7 +171,7 @@ static bool eq_set_band ## band ## _gain(void) \
166 bool result = set_int("Band " #band, str(LANG_UNIT_DB), UNIT_DB, \ 171 bool result = set_int("Band " #band, str(LANG_UNIT_DB), UNIT_DB, \
167 &global_settings.eq_band ## band ## _gain, NULL, \ 172 &global_settings.eq_band ## band ## _gain, NULL, \
168 EQ_GAIN_STEP, EQ_GAIN_MIN, EQ_GAIN_MAX, eq_gain_format); \ 173 EQ_GAIN_STEP, EQ_GAIN_MIN, EQ_GAIN_MAX, eq_gain_format); \
169 dsp_eq_update_data(global_settings.eq_enabled); \ 174 dsp_eq_update_data(global_settings.eq_enabled, band); \
170 return result; \ 175 return result; \
171} 176}
172 177
@@ -648,8 +653,10 @@ bool eq_menu_graphical(void)
648 } 653 }
649 654
650 /* Update the filter if the user changed something */ 655 /* Update the filter if the user changed something */
651 if (has_changed) 656 if (has_changed) {
652 dsp_eq_update_data(global_settings.eq_enabled); 657 dsp_eq_update_data(global_settings.eq_enabled, current_band);
658 has_changed = false;
659 }
653 } 660 }
654 661
655 /* Reset screen settings */ 662 /* Reset screen settings */
diff --git a/apps/settings.c b/apps/settings.c
index 0c62fd2201..4e25bebd95 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -924,6 +924,7 @@ void sound_settings_apply(void)
924void settings_apply(void) 924void settings_apply(void)
925{ 925{
926 char buf[64]; 926 char buf[64];
927 int i;
927 928
928 sound_settings_apply(); 929 sound_settings_apply();
929 930
@@ -1052,7 +1053,11 @@ void settings_apply(void)
1052 audio_set_crossfade(global_settings.crossfade); 1053 audio_set_crossfade(global_settings.crossfade);
1053 dsp_set_replaygain(true); 1054 dsp_set_replaygain(true);
1054 dsp_set_crossfeed(global_settings.crossfeed); 1055 dsp_set_crossfeed(global_settings.crossfeed);
1055 dsp_eq_update_data(global_settings.eq_enabled); 1056
1057 /* Update all EQ bands */
1058 for(i = 0; i < 5; i++) {
1059 dsp_eq_update_data(global_settings.eq_enabled, i);
1060 }
1056#endif 1061#endif
1057 1062
1058#ifdef HAVE_SPDIF_POWER 1063#ifdef HAVE_SPDIF_POWER