Crossfeed settings used to be stored inverted in the cfg file for legacy reasons, change that and kill some identical formatting functions while we're at it. NOTE TO CROSSFEED USERS: this will completely garble your crossfeed settings, write them down if you want to keep them.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15895 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thom Johansen 2007-12-08 01:45:04 +00:00
parent 4c4b3a314a
commit 39e2de8f1b
5 changed files with 26 additions and 41 deletions

View file

@ -758,27 +758,27 @@ void dsp_set_crossfeed(bool enable)
void dsp_set_crossfeed_direct_gain(int gain) void dsp_set_crossfeed_direct_gain(int gain)
{ {
crossfeed_data.gain = get_replaygain_int(gain * -10) << 7; crossfeed_data.gain = get_replaygain_int(gain * 10) << 7;
/* If gain is negative, the calculation overflowed and we need to clamp */ /* If gain is negative, the calculation overflowed and we need to clamp */
if (crossfeed_data.gain < 0) if (crossfeed_data.gain < 0)
crossfeed_data.gain = 0x7fffffff; crossfeed_data.gain = 0x7fffffff;
} }
/* Both gains should be below 0 dB (when inverted) */ /* Both gains should be below 0 dB */
void dsp_set_crossfeed_cross_params(long lf_gain, long hf_gain, long cutoff) void dsp_set_crossfeed_cross_params(long lf_gain, long hf_gain, long cutoff)
{ {
int32_t *c = crossfeed_data.coefs; int32_t *c = crossfeed_data.coefs;
long scaler = get_replaygain_int(lf_gain * -10) << 7; long scaler = get_replaygain_int(lf_gain * 10) << 7;
cutoff = 0xffffffff/NATIVE_FREQUENCY*cutoff; cutoff = 0xffffffff/NATIVE_FREQUENCY*cutoff;
hf_gain -= lf_gain; hf_gain -= lf_gain;
/* Divide cutoff by sqrt(10^(-hf_gain/20)) to place cutoff at the -3 dB /* Divide cutoff by sqrt(10^(hf_gain/20)) to place cutoff at the -3 dB
* point instead of shelf midpoint. This is for compatibility with the old * point instead of shelf midpoint. This is for compatibility with the old
* crossfeed shelf filter and should be removed if crossfeed settings are * crossfeed shelf filter and should be removed if crossfeed settings are
* ever made incompatible for any other good reason. * ever made incompatible for any other good reason.
*/ */
cutoff = DIV64(cutoff, get_replaygain_int(-hf_gain*5), 24); cutoff = DIV64(cutoff, get_replaygain_int(hf_gain*5), 24);
filter_shelf_coefs(cutoff, -hf_gain, false, c); filter_shelf_coefs(cutoff, hf_gain, false, c);
/* Scale coefs by LF gain and shift them to s0.31 format. We have no gains /* Scale coefs by LF gain and shift them to s0.31 format. We have no gains
* over 1 and can do this safely * over 1 and can do this safely
*/ */

View file

@ -51,14 +51,6 @@
* Utility functions * Utility functions
*/ */
void eq_gain_format(char* buffer, size_t buffer_size, int value, const char* unit)
{
int v = abs(value);
snprintf(buffer, buffer_size, "%s%d.%d %s", value < 0 ? "-" : "",
v / EQ_USER_DIVISOR, v % EQ_USER_DIVISOR, unit);
}
void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit) void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit)
{ {
snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit); snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);

View file

@ -41,7 +41,6 @@ bool eq_browse_presets(void);
bool eq_menu_graphical(void); bool eq_menu_graphical(void);
/* utility functions for settings_list.c */ /* utility functions for settings_list.c */
void eq_gain_format(char* buffer, size_t buffer_size, int value, const char* unit);
void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit); void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit);
void eq_precut_format(char* buffer, size_t buffer_size, int value, const char* unit); void eq_precut_format(char* buffer, size_t buffer_size, int value, const char* unit);

View file

@ -556,9 +556,9 @@ struct user_settings
/* Crossfeed settings */ /* Crossfeed settings */
bool crossfeed; /* enable crossfeed */ bool crossfeed; /* enable crossfeed */
unsigned int crossfeed_direct_gain; /* - dB x 10 */ unsigned int crossfeed_direct_gain; /* dB x 10 */
unsigned int crossfeed_cross_gain; /* - dB x 10 */ unsigned int crossfeed_cross_gain; /* dB x 10 */
unsigned int crossfeed_hf_attenuation; /* - dB x 10 */ unsigned int crossfeed_hf_attenuation; /* dB x 10 */
unsigned int crossfeed_hf_cutoff; /* Frequency in Hz */ unsigned int crossfeed_hf_cutoff; /* Frequency in Hz */
#endif #endif
#ifdef HAVE_DIRCACHE #ifdef HAVE_DIRCACHE

View file

@ -250,12 +250,6 @@ static void scanaccel_formatter(char *buffer, size_t buffer_size,
} }
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
static void crossfeed_format(char* buffer, size_t buffer_size, int value,
const char* unit)
{
snprintf(buffer, buffer_size, "%s%d.%d %s", value == 0 ? " " : "-",
value / 10, value % 10, unit);
}
static void crossfeed_cross_set(int val) static void crossfeed_cross_set(int val)
{ {
(void)val; (void)val;
@ -264,7 +258,7 @@ static void crossfeed_cross_set(int val)
global_settings.crossfeed_hf_cutoff); global_settings.crossfeed_hf_cutoff);
} }
static void replaygain_preamp_format(char* buffer, size_t buffer_size, int value, static void db_format(char* buffer, size_t buffer_size, int value,
const char* unit) const char* unit)
{ {
int v = abs(value); int v = abs(value);
@ -274,7 +268,7 @@ static void replaygain_preamp_format(char* buffer, size_t buffer_size, int value
} }
#endif #endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC -= MAS3539F)
static void set_mdb_enable(bool value) static void set_mdb_enable(bool value)
{ {
sound_set_mdb_enable((int)value); sound_set_mdb_enable((int)value);
@ -868,7 +862,7 @@ const struct settings_list settings[] = {
OFFON_SETTING(0, replaygain_noclip, LANG_REPLAYGAIN_NOCLIP, OFFON_SETTING(0, replaygain_noclip, LANG_REPLAYGAIN_NOCLIP,
false, "replaygain noclip", NULL), false, "replaygain noclip", NULL),
INT_SETTING_NOWRAP(0, replaygain_preamp, LANG_REPLAYGAIN_PREAMP, 0, "replaygain preamp", INT_SETTING_NOWRAP(0, replaygain_preamp, LANG_REPLAYGAIN_PREAMP, 0, "replaygain preamp",
UNIT_DB, -120, 120, 5, replaygain_preamp_format, NULL, NULL), UNIT_DB, -120, 120, 5, db_format, NULL, NULL),
CHOICE_SETTING(0, beep, LANG_BEEP, 0, CHOICE_SETTING(0, beep, LANG_BEEP, 0,
"beep", "off,weak,moderate,strong", NULL, 4, "beep", "off,weak,moderate,strong", NULL, 4,
@ -894,15 +888,15 @@ const struct settings_list settings[] = {
/* crossfeed */ /* crossfeed */
OFFON_SETTING(0,crossfeed, LANG_CROSSFEED, false, OFFON_SETTING(0,crossfeed, LANG_CROSSFEED, false,
"crossfeed", dsp_set_crossfeed), "crossfeed", dsp_set_crossfeed),
INT_SETTING_NOWRAP(0, crossfeed_direct_gain, LANG_CROSSFEED_DIRECT_GAIN, 15, INT_SETTING_NOWRAP(0, crossfeed_direct_gain, LANG_CROSSFEED_DIRECT_GAIN,
"crossfeed direct gain", UNIT_DB, 0, 60, 5, -15, "crossfeed direct gain", UNIT_DB, -60, 0, 5,
crossfeed_format, NULL, dsp_set_crossfeed_direct_gain), db_format, NULL, dsp_set_crossfeed_direct_gain),
INT_SETTING_NOWRAP(0, crossfeed_cross_gain, LANG_CROSSFEED_CROSS_GAIN, 60, INT_SETTING_NOWRAP(0, crossfeed_cross_gain, LANG_CROSSFEED_CROSS_GAIN, -60,
"crossfeed cross gain", UNIT_DB, 30, 120, 5, "crossfeed cross gain", UNIT_DB, -120, -30, 5,
crossfeed_format, NULL, crossfeed_cross_set), db_format, NULL, crossfeed_cross_set),
INT_SETTING_NOWRAP(0, crossfeed_hf_attenuation, LANG_CROSSFEED_HF_ATTENUATION, 160, INT_SETTING_NOWRAP(0, crossfeed_hf_attenuation, LANG_CROSSFEED_HF_ATTENUATION, -160,
"crossfeed hf attenuation", UNIT_DB, 60, 240, 5, "crossfeed hf attenuation", UNIT_DB, -240, -60, 5,
crossfeed_format, NULL, crossfeed_cross_set), db_format, NULL, crossfeed_cross_set),
INT_SETTING_NOWRAP(0, crossfeed_hf_cutoff, LANG_CROSSFEED_HF_CUTOFF, 700, INT_SETTING_NOWRAP(0, crossfeed_hf_cutoff, LANG_CROSSFEED_HF_CUTOFF, 700,
"crossfeed hf cutoff", UNIT_HERTZ, 500, 2000, 100, "crossfeed hf cutoff", UNIT_HERTZ, 500, 2000, 100,
NULL, NULL, crossfeed_cross_set), NULL, NULL, crossfeed_cross_set),
@ -948,19 +942,19 @@ const struct settings_list settings[] = {
/* -240..240 (or -24db to +24db) */ /* -240..240 (or -24db to +24db) */
INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_gain, LANG_GAIN, 0, INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_gain, LANG_GAIN, 0,
"eq band 0 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, "eq band 0 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
EQ_GAIN_STEP, eq_gain_format, NULL, NULL), EQ_GAIN_STEP, db_format, NULL, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_gain, LANG_GAIN, 0, INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_gain, LANG_GAIN, 0,
"eq band 1 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, "eq band 1 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
EQ_GAIN_STEP, eq_gain_format, NULL, NULL), EQ_GAIN_STEP, db_format, NULL, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_gain, LANG_GAIN, 0, INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_gain, LANG_GAIN, 0,
"eq band 2 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, "eq band 2 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
EQ_GAIN_STEP, eq_gain_format, NULL, NULL), EQ_GAIN_STEP, db_format, NULL, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_gain, LANG_GAIN, 0, INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_gain, LANG_GAIN, 0,
"eq band 3 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, "eq band 3 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
EQ_GAIN_STEP, eq_gain_format, NULL, NULL), EQ_GAIN_STEP, db_format, NULL, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_gain, LANG_GAIN, 0, INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_gain, LANG_GAIN, 0,
"eq band 4 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, "eq band 4 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
EQ_GAIN_STEP, eq_gain_format, NULL, NULL), EQ_GAIN_STEP, db_format, NULL, NULL),
/* dithering */ /* dithering */
OFFON_SETTING(0, dithering_enabled, LANG_DITHERING, OFFON_SETTING(0, dithering_enabled, LANG_DITHERING,