summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Cerneels <bart.cerneels@kde.org>2011-05-28 07:57:22 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2011-05-28 07:59:07 +0530
commit9e78de2da27e882b8cd956ec859304629011a55b (patch)
treebf6889cc2726ca66af5351ba7cad55ac5e96ef7d /src
parent4fd3efa46b33726d489af933e709289d20ed5ea0 (diff)
echo-cancel: Fix echo suppression, add some knobs
The echo suppress attenuation value was being incorrectly modified. Fixed and added 2 arguments to change the attenuation of the residual echo filter. Default values of the speex preprocessor will be used when omitted.
Diffstat (limited to 'src')
-rw-r--r--src/modules/echo-cancel/echo-cancel.h2
-rw-r--r--src/modules/echo-cancel/module-echo-cancel.c37
2 files changed, 36 insertions, 3 deletions
diff --git a/src/modules/echo-cancel/echo-cancel.h b/src/modules/echo-cancel/echo-cancel.h
index 5f18053c2..aa40adced 100644
--- a/src/modules/echo-cancel/echo-cancel.h
+++ b/src/modules/echo-cancel/echo-cancel.h
@@ -68,6 +68,8 @@ struct pa_echo_canceller {
pa_bool_t agc;
pa_bool_t denoise;
pa_bool_t echo_suppress;
+ int32_t echo_suppress_attenuation;
+ int32_t echo_suppress_attenuation_active;
SpeexPreprocessState *pp_state;
};
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index 90577d4cb..cb3083293 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -79,7 +79,9 @@ PA_MODULE_USAGE(
"aec_args=<parameters for the AEC engine> "
"agc=<perform automagic gain control?> "
"denoise=<apply denoising?> "
- "echo_suppress=<perform echo suppression? (only with the speex canceller)> "
+ "echo_suppress=<perform residual echo suppression? (only with the speex canceller)> "
+ "echo_suppress_attenuation=<dB value of residual echo attenuation> "
+ "echo_suppress_attenuation_active=<dB value of residual echo attenuation when near end is active> "
"save_aec=<save AEC data in /tmp> "
"autoloaded=<set if this module is being loaded automatically> "
));
@@ -112,6 +114,7 @@ static const pa_echo_canceller ec_table[] = {
#define DEFAULT_AGC_ENABLED FALSE
#define DEFAULT_DENOISE_ENABLED FALSE
#define DEFAULT_ECHO_SUPPRESS_ENABLED FALSE
+#define DEFAULT_ECHO_SUPPRESS_ATTENUATION 0
#define DEFAULT_SAVE_AEC 0
#define DEFAULT_AUTOLOADED FALSE
@@ -221,6 +224,8 @@ static const char* const valid_modargs[] = {
"agc",
"denoise",
"echo_suppress",
+ "echo_suppress_attenuation",
+ "echo_suppress_attenuation_active",
"save_aec",
"autoloaded",
NULL
@@ -1429,6 +1434,26 @@ int pa__init(pa_module*m) {
goto fail;
}
+ u->ec->echo_suppress_attenuation = DEFAULT_ECHO_SUPPRESS_ATTENUATION;
+ if (pa_modargs_get_value_s32(ma, "echo_suppress_attenuation", &u->ec->echo_suppress_attenuation) < 0) {
+ pa_log("Failed to parse echo_suppress_attenuation value");
+ goto fail;
+ }
+ if (u->ec->echo_suppress_attenuation > 0) {
+ pa_log("echo_suppress_attenuation should be a negative dB value");
+ goto fail;
+ }
+
+ u->ec->echo_suppress_attenuation_active = DEFAULT_ECHO_SUPPRESS_ATTENUATION;
+ if (pa_modargs_get_value_s32(ma, "echo_suppress_attenuation_active", &u->ec->echo_suppress_attenuation_active) < 0) {
+ pa_log("Failed to parse echo_supress_attenuation_active value");
+ goto fail;
+ }
+ if (u->ec->echo_suppress_attenuation_active > 0) {
+ pa_log("echo_suppress_attenuation_active should be a negative dB value");
+ goto fail;
+ }
+
u->save_aec = DEFAULT_SAVE_AEC;
if (pa_modargs_get_value_u32(ma, "save_aec", &u->save_aec) < 0) {
pa_log("Failed to parse save_aec value");
@@ -1460,9 +1485,15 @@ int pa__init(pa_module*m) {
speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_AGC, &u->ec->agc);
speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_DENOISE, &u->ec->denoise);
- speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS, &u->ec->echo_suppress);
- if (u->ec->echo_suppress)
+ if (u->ec->echo_suppress) {
+ if (u->ec->echo_suppress_attenuation)
+ speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS, &u->ec->echo_suppress_attenuation);
+ if (u->ec->echo_suppress_attenuation_active) {
+ speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE,
+ &u->ec->echo_suppress_attenuation_active);
+ }
speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_ECHO_STATE, u->ec->params.priv.speex.state);
+ }
}
/* Create source */