mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-23 08:56:40 -05:00
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.
This commit is contained in:
parent
4fd3efa46b
commit
9e78de2da2
2 changed files with 36 additions and 3 deletions
|
|
@ -68,6 +68,8 @@ struct pa_echo_canceller {
|
||||||
pa_bool_t agc;
|
pa_bool_t agc;
|
||||||
pa_bool_t denoise;
|
pa_bool_t denoise;
|
||||||
pa_bool_t echo_suppress;
|
pa_bool_t echo_suppress;
|
||||||
|
int32_t echo_suppress_attenuation;
|
||||||
|
int32_t echo_suppress_attenuation_active;
|
||||||
SpeexPreprocessState *pp_state;
|
SpeexPreprocessState *pp_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,9 @@ PA_MODULE_USAGE(
|
||||||
"aec_args=<parameters for the AEC engine> "
|
"aec_args=<parameters for the AEC engine> "
|
||||||
"agc=<perform automagic gain control?> "
|
"agc=<perform automagic gain control?> "
|
||||||
"denoise=<apply denoising?> "
|
"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> "
|
"save_aec=<save AEC data in /tmp> "
|
||||||
"autoloaded=<set if this module is being loaded automatically> "
|
"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_AGC_ENABLED FALSE
|
||||||
#define DEFAULT_DENOISE_ENABLED FALSE
|
#define DEFAULT_DENOISE_ENABLED FALSE
|
||||||
#define DEFAULT_ECHO_SUPPRESS_ENABLED FALSE
|
#define DEFAULT_ECHO_SUPPRESS_ENABLED FALSE
|
||||||
|
#define DEFAULT_ECHO_SUPPRESS_ATTENUATION 0
|
||||||
#define DEFAULT_SAVE_AEC 0
|
#define DEFAULT_SAVE_AEC 0
|
||||||
#define DEFAULT_AUTOLOADED FALSE
|
#define DEFAULT_AUTOLOADED FALSE
|
||||||
|
|
||||||
|
|
@ -221,6 +224,8 @@ static const char* const valid_modargs[] = {
|
||||||
"agc",
|
"agc",
|
||||||
"denoise",
|
"denoise",
|
||||||
"echo_suppress",
|
"echo_suppress",
|
||||||
|
"echo_suppress_attenuation",
|
||||||
|
"echo_suppress_attenuation_active",
|
||||||
"save_aec",
|
"save_aec",
|
||||||
"autoloaded",
|
"autoloaded",
|
||||||
NULL
|
NULL
|
||||||
|
|
@ -1429,6 +1434,26 @@ int pa__init(pa_module*m) {
|
||||||
goto fail;
|
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;
|
u->save_aec = DEFAULT_SAVE_AEC;
|
||||||
if (pa_modargs_get_value_u32(ma, "save_aec", &u->save_aec) < 0) {
|
if (pa_modargs_get_value_u32(ma, "save_aec", &u->save_aec) < 0) {
|
||||||
pa_log("Failed to parse save_aec value");
|
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_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_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);
|
speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_ECHO_STATE, u->ec->params.priv.speex.state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create source */
|
/* Create source */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue