Update equalizer precut value as it's adjusted.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9332 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dan Everton 2006-03-28 21:19:30 +00:00
parent fc9bc17335
commit daebff8b5d
4 changed files with 27 additions and 18 deletions

View file

@ -591,15 +591,22 @@ static void apply_crossfeed(int32_t* src[], int count)
#endif #endif
/** /**
* Use to enable the equalizer and set any pregain. * Use to enable the equalizer.
* *
* @param enable true to enable the equalizer * @param enable true to enable the equalizer
* @param precut to apply in decibels (multiplied by 10)
*/ */
void dsp_eq_set(bool enable, unsigned int precut) void dsp_set_eq(bool enable)
{ {
dsp->eq_enabled = enable; dsp->eq_enabled = enable;
}
/**
* Update the amount to cut the audio before applying the equalizer.
*
* @param precut to apply in decibels (multiplied by 10)
*/
void dsp_set_eq_precut(int precut)
{
/* Needs to be in s8.23 format amplitude for apply_gain() */ /* Needs to be in s8.23 format amplitude for apply_gain() */
dsp->eq_precut = get_replaygain_int(precut * -10) >> 1; dsp->eq_precut = get_replaygain_int(precut * -10) >> 1;
} }
@ -609,7 +616,7 @@ void dsp_eq_set(bool enable, unsigned int precut)
* *
* @param band the equalizer band to synchronize * @param band the equalizer band to synchronize
*/ */
void dsp_eq_update_filter_coefs(int band) void dsp_set_eq_coefs(int band)
{ {
const int *setting; const int *setting;
long gain; long gain;

View file

@ -54,8 +54,9 @@ int dsp_stereo_mode(void);
bool dsp_configure(int setting, void *value); bool dsp_configure(int setting, void *value);
void dsp_set_replaygain(bool always); void dsp_set_replaygain(bool always);
void dsp_set_crossfeed(bool enable); void dsp_set_crossfeed(bool enable);
void dsp_eq_set(bool enable, unsigned int precut); void dsp_set_eq(bool enable);
void dsp_eq_update_filter_coefs(int band); void dsp_set_eq_precut(int precut);
void dsp_set_eq_coefs(int band);
void sound_set_pitch(int r); void sound_set_pitch(int r);
int sound_get_pitch(void); int sound_get_pitch(void);
void channels_set(int value); void channels_set(int value);

View file

@ -147,11 +147,13 @@ static bool eq_enabled(void)
bool result = set_bool(str(LANG_EQUALIZER_ENABLED), bool result = set_bool(str(LANG_EQUALIZER_ENABLED),
&global_settings.eq_enabled); &global_settings.eq_enabled);
dsp_eq_set(global_settings.eq_enabled, global_settings.eq_precut); dsp_set_eq(global_settings.eq_enabled);
dsp_set_eq_precut(global_settings.eq_precut);
/* Update all bands */ /* Update all bands */
for(i = 0; i < 5; i++) { for(i = 0; i < 5; i++) {
dsp_eq_update_filter_coefs(i); dsp_set_eq_coefs(i);
} }
return result; return result;
@ -160,11 +162,9 @@ static bool eq_enabled(void)
static bool eq_precut(void) static bool eq_precut(void)
{ {
bool result = set_int(str(LANG_EQUALIZER_PRECUT), str(LANG_UNIT_DB), bool result = set_int(str(LANG_EQUALIZER_PRECUT), str(LANG_UNIT_DB),
UNIT_DB, &global_settings.eq_precut, NULL, 5, 0, 240, UNIT_DB, &global_settings.eq_precut, dsp_set_eq_precut, 5, 0, 240,
eq_precut_format); eq_precut_format);
dsp_eq_set(global_settings.eq_enabled, global_settings.eq_precut);
return result; return result;
} }
@ -178,7 +178,7 @@ static bool eq_set_band ## band ## _center(void) \
bool result = set_int(str(LANG_EQUALIZER_BAND_CENTER), "Hertz", \ bool result = set_int(str(LANG_EQUALIZER_BAND_CENTER), "Hertz", \
UNIT_HERTZ, &global_settings.eq_band ## band ## _cutoff, NULL, \ UNIT_HERTZ, &global_settings.eq_band ## band ## _cutoff, NULL, \
EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \ EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \
dsp_eq_update_filter_coefs(band); \ dsp_set_eq_coefs(band); \
return result; \ return result; \
} }
@ -188,7 +188,7 @@ static bool eq_set_band ## band ## _cutoff(void) \
bool result = set_int(str(LANG_EQUALIZER_BAND_CUTOFF), "Hertz", \ bool result = set_int(str(LANG_EQUALIZER_BAND_CUTOFF), "Hertz", \
UNIT_HERTZ, &global_settings.eq_band ## band ## _cutoff, NULL, \ UNIT_HERTZ, &global_settings.eq_band ## band ## _cutoff, NULL, \
EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \ EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \
dsp_eq_update_filter_coefs(band); \ dsp_set_eq_coefs(band); \
return result; \ return result; \
} }
@ -198,7 +198,7 @@ static bool eq_set_band ## band ## _q(void) \
bool result = set_int(str(LANG_EQUALIZER_BAND_Q), "Q", UNIT_INT, \ bool result = set_int(str(LANG_EQUALIZER_BAND_Q), "Q", UNIT_INT, \
&global_settings.eq_band ## band ## _q, NULL, \ &global_settings.eq_band ## band ## _q, NULL, \
EQ_Q_STEP, EQ_Q_MIN, EQ_Q_MAX, eq_q_format); \ EQ_Q_STEP, EQ_Q_MIN, EQ_Q_MAX, eq_q_format); \
dsp_eq_update_filter_coefs(band); \ dsp_set_eq_coefs(band); \
return result; \ return result; \
} }
@ -208,7 +208,7 @@ static bool eq_set_band ## band ## _gain(void) \
bool result = set_int("Band " #band, str(LANG_UNIT_DB), UNIT_DB, \ bool result = set_int("Band " #band, str(LANG_UNIT_DB), UNIT_DB, \
&global_settings.eq_band ## band ## _gain, NULL, \ &global_settings.eq_band ## band ## _gain, NULL, \
EQ_GAIN_STEP, EQ_GAIN_MIN, EQ_GAIN_MAX, eq_gain_format); \ EQ_GAIN_STEP, EQ_GAIN_MIN, EQ_GAIN_MAX, eq_gain_format); \
dsp_eq_update_filter_coefs(band); \ dsp_set_eq_coefs(band); \
return result; \ return result; \
} }
@ -693,7 +693,7 @@ bool eq_menu_graphical(void)
/* Update the filter if the user changed something */ /* Update the filter if the user changed something */
if (has_changed) { if (has_changed) {
dsp_eq_update_filter_coefs(current_band); dsp_set_eq_coefs(current_band);
has_changed = false; has_changed = false;
} }
} }

View file

@ -1130,10 +1130,11 @@ void settings_apply(void)
dsp_set_replaygain(true); dsp_set_replaygain(true);
dsp_set_crossfeed(global_settings.crossfeed); dsp_set_crossfeed(global_settings.crossfeed);
dsp_eq_set(global_settings.eq_enabled, global_settings.eq_precut); dsp_set_eq(global_settings.eq_enabled);
dsp_set_eq_precut(global_settings.eq_precut);
/* Update all EQ bands */ /* Update all EQ bands */
for(i = 0; i < 5; i++) { for(i = 0; i < 5; i++) {
dsp_eq_update_filter_coefs(i); dsp_set_eq_coefs(i);
} }
#endif #endif