summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/dsp.c12
-rw-r--r--apps/menus/eq_menu.c8
-rw-r--r--apps/menus/eq_menu.h1
-rw-r--r--apps/settings.h6
-rw-r--r--apps/settings_list.c40
5 files changed, 26 insertions, 41 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index 1e0ae1fb8d..3c2d7f63b1 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -758,27 +758,27 @@ void dsp_set_crossfeed(bool enable)
758 758
759void dsp_set_crossfeed_direct_gain(int gain) 759void dsp_set_crossfeed_direct_gain(int gain)
760{ 760{
761 crossfeed_data.gain = get_replaygain_int(gain * -10) << 7; 761 crossfeed_data.gain = get_replaygain_int(gain * 10) << 7;
762 /* If gain is negative, the calculation overflowed and we need to clamp */ 762 /* If gain is negative, the calculation overflowed and we need to clamp */
763 if (crossfeed_data.gain < 0) 763 if (crossfeed_data.gain < 0)
764 crossfeed_data.gain = 0x7fffffff; 764 crossfeed_data.gain = 0x7fffffff;
765} 765}
766 766
767/* Both gains should be below 0 dB (when inverted) */ 767/* Both gains should be below 0 dB */
768void dsp_set_crossfeed_cross_params(long lf_gain, long hf_gain, long cutoff) 768void dsp_set_crossfeed_cross_params(long lf_gain, long hf_gain, long cutoff)
769{ 769{
770 int32_t *c = crossfeed_data.coefs; 770 int32_t *c = crossfeed_data.coefs;
771 long scaler = get_replaygain_int(lf_gain * -10) << 7; 771 long scaler = get_replaygain_int(lf_gain * 10) << 7;
772 772
773 cutoff = 0xffffffff/NATIVE_FREQUENCY*cutoff; 773 cutoff = 0xffffffff/NATIVE_FREQUENCY*cutoff;
774 hf_gain -= lf_gain; 774 hf_gain -= lf_gain;
775 /* Divide cutoff by sqrt(10^(-hf_gain/20)) to place cutoff at the -3 dB 775 /* Divide cutoff by sqrt(10^(hf_gain/20)) to place cutoff at the -3 dB
776 * point instead of shelf midpoint. This is for compatibility with the old 776 * point instead of shelf midpoint. This is for compatibility with the old
777 * crossfeed shelf filter and should be removed if crossfeed settings are 777 * crossfeed shelf filter and should be removed if crossfeed settings are
778 * ever made incompatible for any other good reason. 778 * ever made incompatible for any other good reason.
779 */ 779 */
780 cutoff = DIV64(cutoff, get_replaygain_int(-hf_gain*5), 24); 780 cutoff = DIV64(cutoff, get_replaygain_int(hf_gain*5), 24);
781 filter_shelf_coefs(cutoff, -hf_gain, false, c); 781 filter_shelf_coefs(cutoff, hf_gain, false, c);
782 /* Scale coefs by LF gain and shift them to s0.31 format. We have no gains 782 /* Scale coefs by LF gain and shift them to s0.31 format. We have no gains
783 * over 1 and can do this safely 783 * over 1 and can do this safely
784 */ 784 */
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c
index b3e67e42ef..1dbb5541c5 100644
--- a/apps/menus/eq_menu.c
+++ b/apps/menus/eq_menu.c
@@ -51,14 +51,6 @@
51 * Utility functions 51 * Utility functions
52 */ 52 */
53 53
54void eq_gain_format(char* buffer, size_t buffer_size, int value, const char* unit)
55{
56 int v = abs(value);
57
58 snprintf(buffer, buffer_size, "%s%d.%d %s", value < 0 ? "-" : "",
59 v / EQ_USER_DIVISOR, v % EQ_USER_DIVISOR, unit);
60}
61
62void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit) 54void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit)
63{ 55{
64 snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit); 56 snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);
diff --git a/apps/menus/eq_menu.h b/apps/menus/eq_menu.h
index ebeedff787..cc73d7bff0 100644
--- a/apps/menus/eq_menu.h
+++ b/apps/menus/eq_menu.h
@@ -41,7 +41,6 @@ bool eq_browse_presets(void);
41bool eq_menu_graphical(void); 41bool eq_menu_graphical(void);
42 42
43/* utility functions for settings_list.c */ 43/* utility functions for settings_list.c */
44void eq_gain_format(char* buffer, size_t buffer_size, int value, const char* unit);
45void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit); 44void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit);
46void eq_precut_format(char* buffer, size_t buffer_size, int value, const char* unit); 45void eq_precut_format(char* buffer, size_t buffer_size, int value, const char* unit);
47 46
diff --git a/apps/settings.h b/apps/settings.h
index 0e4e627005..d0e2a490a4 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -556,9 +556,9 @@ struct user_settings
556 556
557 /* Crossfeed settings */ 557 /* Crossfeed settings */
558 bool crossfeed; /* enable crossfeed */ 558 bool crossfeed; /* enable crossfeed */
559 unsigned int crossfeed_direct_gain; /* - dB x 10 */ 559 unsigned int crossfeed_direct_gain; /* dB x 10 */
560 unsigned int crossfeed_cross_gain; /* - dB x 10 */ 560 unsigned int crossfeed_cross_gain; /* dB x 10 */
561 unsigned int crossfeed_hf_attenuation; /* - dB x 10 */ 561 unsigned int crossfeed_hf_attenuation; /* dB x 10 */
562 unsigned int crossfeed_hf_cutoff; /* Frequency in Hz */ 562 unsigned int crossfeed_hf_cutoff; /* Frequency in Hz */
563#endif 563#endif
564#ifdef HAVE_DIRCACHE 564#ifdef HAVE_DIRCACHE
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 3d5075ce3f..0759b46940 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -250,12 +250,6 @@ static void scanaccel_formatter(char *buffer, size_t buffer_size,
250} 250}
251 251
252#if CONFIG_CODEC == SWCODEC 252#if CONFIG_CODEC == SWCODEC
253static void crossfeed_format(char* buffer, size_t buffer_size, int value,
254 const char* unit)
255{
256 snprintf(buffer, buffer_size, "%s%d.%d %s", value == 0 ? " " : "-",
257 value / 10, value % 10, unit);
258}
259static void crossfeed_cross_set(int val) 253static void crossfeed_cross_set(int val)
260{ 254{
261 (void)val; 255 (void)val;
@@ -264,7 +258,7 @@ static void crossfeed_cross_set(int val)
264 global_settings.crossfeed_hf_cutoff); 258 global_settings.crossfeed_hf_cutoff);
265} 259}
266 260
267static void replaygain_preamp_format(char* buffer, size_t buffer_size, int value, 261static void db_format(char* buffer, size_t buffer_size, int value,
268 const char* unit) 262 const char* unit)
269{ 263{
270 int v = abs(value); 264 int v = abs(value);
@@ -274,7 +268,7 @@ static void replaygain_preamp_format(char* buffer, size_t buffer_size, int value
274} 268}
275 269
276#endif 270#endif
277#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) 271#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC -= MAS3539F)
278static void set_mdb_enable(bool value) 272static void set_mdb_enable(bool value)
279{ 273{
280 sound_set_mdb_enable((int)value); 274 sound_set_mdb_enable((int)value);
@@ -868,7 +862,7 @@ const struct settings_list settings[] = {
868 OFFON_SETTING(0, replaygain_noclip, LANG_REPLAYGAIN_NOCLIP, 862 OFFON_SETTING(0, replaygain_noclip, LANG_REPLAYGAIN_NOCLIP,
869 false, "replaygain noclip", NULL), 863 false, "replaygain noclip", NULL),
870 INT_SETTING_NOWRAP(0, replaygain_preamp, LANG_REPLAYGAIN_PREAMP, 0, "replaygain preamp", 864 INT_SETTING_NOWRAP(0, replaygain_preamp, LANG_REPLAYGAIN_PREAMP, 0, "replaygain preamp",
871 UNIT_DB, -120, 120, 5, replaygain_preamp_format, NULL, NULL), 865 UNIT_DB, -120, 120, 5, db_format, NULL, NULL),
872 866
873 CHOICE_SETTING(0, beep, LANG_BEEP, 0, 867 CHOICE_SETTING(0, beep, LANG_BEEP, 0,
874 "beep", "off,weak,moderate,strong", NULL, 4, 868 "beep", "off,weak,moderate,strong", NULL, 4,
@@ -894,15 +888,15 @@ const struct settings_list settings[] = {
894 /* crossfeed */ 888 /* crossfeed */
895 OFFON_SETTING(0,crossfeed, LANG_CROSSFEED, false, 889 OFFON_SETTING(0,crossfeed, LANG_CROSSFEED, false,
896 "crossfeed", dsp_set_crossfeed), 890 "crossfeed", dsp_set_crossfeed),
897 INT_SETTING_NOWRAP(0, crossfeed_direct_gain, LANG_CROSSFEED_DIRECT_GAIN, 15, 891 INT_SETTING_NOWRAP(0, crossfeed_direct_gain, LANG_CROSSFEED_DIRECT_GAIN,
898 "crossfeed direct gain", UNIT_DB, 0, 60, 5, 892 -15, "crossfeed direct gain", UNIT_DB, -60, 0, 5,
899 crossfeed_format, NULL, dsp_set_crossfeed_direct_gain), 893 db_format, NULL, dsp_set_crossfeed_direct_gain),
900 INT_SETTING_NOWRAP(0, crossfeed_cross_gain, LANG_CROSSFEED_CROSS_GAIN, 60, 894 INT_SETTING_NOWRAP(0, crossfeed_cross_gain, LANG_CROSSFEED_CROSS_GAIN, -60,
901 "crossfeed cross gain", UNIT_DB, 30, 120, 5, 895 "crossfeed cross gain", UNIT_DB, -120, -30, 5,
902 crossfeed_format, NULL, crossfeed_cross_set), 896 db_format, NULL, crossfeed_cross_set),
903 INT_SETTING_NOWRAP(0, crossfeed_hf_attenuation, LANG_CROSSFEED_HF_ATTENUATION, 160, 897 INT_SETTING_NOWRAP(0, crossfeed_hf_attenuation, LANG_CROSSFEED_HF_ATTENUATION, -160,
904 "crossfeed hf attenuation", UNIT_DB, 60, 240, 5, 898 "crossfeed hf attenuation", UNIT_DB, -240, -60, 5,
905 crossfeed_format, NULL, crossfeed_cross_set), 899 db_format, NULL, crossfeed_cross_set),
906 INT_SETTING_NOWRAP(0, crossfeed_hf_cutoff, LANG_CROSSFEED_HF_CUTOFF, 700, 900 INT_SETTING_NOWRAP(0, crossfeed_hf_cutoff, LANG_CROSSFEED_HF_CUTOFF, 700,
907 "crossfeed hf cutoff", UNIT_HERTZ, 500, 2000, 100, 901 "crossfeed hf cutoff", UNIT_HERTZ, 500, 2000, 100,
908 NULL, NULL, crossfeed_cross_set), 902 NULL, NULL, crossfeed_cross_set),
@@ -948,19 +942,19 @@ const struct settings_list settings[] = {
948 /* -240..240 (or -24db to +24db) */ 942 /* -240..240 (or -24db to +24db) */
949 INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_gain, LANG_GAIN, 0, 943 INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_gain, LANG_GAIN, 0,
950 "eq band 0 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, 944 "eq band 0 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
951 EQ_GAIN_STEP, eq_gain_format, NULL, NULL), 945 EQ_GAIN_STEP, db_format, NULL, NULL),
952 INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_gain, LANG_GAIN, 0, 946 INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_gain, LANG_GAIN, 0,
953 "eq band 1 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, 947 "eq band 1 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
954 EQ_GAIN_STEP, eq_gain_format, NULL, NULL), 948 EQ_GAIN_STEP, db_format, NULL, NULL),
955 INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_gain, LANG_GAIN, 0, 949 INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_gain, LANG_GAIN, 0,
956 "eq band 2 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, 950 "eq band 2 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
957 EQ_GAIN_STEP, eq_gain_format, NULL, NULL), 951 EQ_GAIN_STEP, db_format, NULL, NULL),
958 INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_gain, LANG_GAIN, 0, 952 INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_gain, LANG_GAIN, 0,
959 "eq band 3 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, 953 "eq band 3 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
960 EQ_GAIN_STEP, eq_gain_format, NULL, NULL), 954 EQ_GAIN_STEP, db_format, NULL, NULL),
961 INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_gain, LANG_GAIN, 0, 955 INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_gain, LANG_GAIN, 0,
962 "eq band 4 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, 956 "eq band 4 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
963 EQ_GAIN_STEP, eq_gain_format, NULL, NULL), 957 EQ_GAIN_STEP, db_format, NULL, NULL),
964 958
965 /* dithering */ 959 /* dithering */
966 OFFON_SETTING(0, dithering_enabled, LANG_DITHERING, 960 OFFON_SETTING(0, dithering_enabled, LANG_DITHERING,