Index: apps/lang/english.lang
===================================================================
--- apps/lang/english.lang (revision 20909)
+++ apps/lang/english.lang (working copy)
@@ -12468,3 +12468,20 @@
*: "Prevent Track Skipping"
+
+ id: LANG_COMPRESSION
+ desc: in sound settings
+ user: core
+
+ *: none
+ swcodec: "Compression"
+
+
+ *: none
+ swcodec: "Compression"
+
+
+ *: none
+ swcodec: "Compression"
+
+
Index: apps/settings.c
===================================================================
--- apps/settings.c (revision 20909)
+++ apps/settings.c (working copy)
@@ -936,6 +936,7 @@
}
dsp_dither_enable(global_settings.dithering_enabled);
+ dsp_set_compression_level(global_settings.compression_level);
#endif
#ifdef HAVE_SPDIF_POWER
Index: apps/settings.h
===================================================================
--- apps/settings.h (revision 20909)
+++ apps/settings.h (working copy)
@@ -731,6 +731,10 @@
int touch_mode;
#endif
+#if CONFIG_CODEC == SWCODEC
+ int compression_level;
+#endif
+
/* If values are just added to the end, no need to bump plugin API
version. */
/* new stuff to be added at the end */
Index: apps/menus/sound_menu.c
===================================================================
--- apps/menus/sound_menu.c (revision 20909)
+++ apps/menus/sound_menu.c (working copy)
@@ -89,6 +89,10 @@
MENUITEM_SETTING(dithering_enabled,
&global_settings.dithering_enabled, lowlatency_callback);
+
+ MENUITEM_SETTING(compression_level,
+ &global_settings.compression_level, lowlatency_callback);
+
#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
@@ -121,6 +125,7 @@
&balance,&channel_config,&stereo_width
#if CONFIG_CODEC == SWCODEC
,&crossfeed_menu, &equalizer_menu, &dithering_enabled
+ ,&compression_level
#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
,&loudness,&avc,&superbass,&mdb_enable,&mdb_strength
Index: apps/dsp.c
===================================================================
--- apps/dsp.c (revision 20909)
+++ apps/dsp.c (working copy)
@@ -217,6 +217,8 @@
static long album_peak;
static long replaygain;
static bool crossfeed_enabled;
+static bool compression_enabled;
+static float compression_gain;
#define audio_dsp (dsp_conf[CODEC_IDX_AUDIO])
#define voice_dsp (dsp_conf[CODEC_IDX_VOICE])
@@ -1405,3 +1407,10 @@
replaygain = gain;
set_gain(&audio_dsp);
}
+
+void dsp_set_compression_level(int compression_level)
+/* initializes compression */
+{
+ compression_gain = compression_level / 10.0;
+ compression_enabled = (compression_level > 0);
+}
Index: apps/dsp.h
===================================================================
--- apps/dsp.h (revision 20909)
+++ apps/dsp.h (working copy)
@@ -26,6 +26,9 @@
#include
#define NATIVE_FREQUENCY 44100
+
+#define MAX_COMPRESSION_GAIN 200 /* 20 dB */
+
enum
{
STEREO_INTERLEAVED = 0,
@@ -164,5 +167,6 @@
int sound_get_pitch(void);
int dsp_callback(int msg, intptr_t param);
void dsp_dither_enable(bool enable);
+void dsp_set_compression_level(int compression_level);
#endif
Index: apps/settings_list.c
===================================================================
--- apps/settings_list.c (revision 20909)
+++ apps/settings_list.c (working copy)
@@ -1181,6 +1181,13 @@
/* dithering */
OFFON_SETTING(F_SOUNDSETTING, dithering_enabled, LANG_DITHERING, false,
"dithering enabled", dsp_dither_enable),
+
+ /* compression */
+ INT_SETTING_NOWRAP(F_SOUNDSETTING, compression_level,
+ LANG_COMPRESSION, 0,
+ "compression level", UNIT_DB, 0, MAX_COMPRESSION_GAIN,
+ 5, db_format, get_dec_talkid, dsp_set_compression_level),
+
#endif
#ifdef HAVE_WM8758
SOUND_SETTING(F_NO_WRAP, bass_cutoff, LANG_BASS_CUTOFF,