Commit 5ed2238d authored by smorlat's avatar smorlat
Browse files

add threshold for noise gate.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@603 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 78086509
No related merge requests found
Showing with 12 additions and 1 deletion
......@@ -52,6 +52,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MS_VOLUME_ENABLE_NOISE_GATE MS_FILTER_METHOD(MS_VOLUME_ID,9,int)
#define MS_VOLUME_SET_NOISE_GATE_THRESHOLD MS_FILTER_METHOD(MS_VOLUME_ID,10,float)
extern MSFilterDesc ms_volume_desc;
#endif
......@@ -52,6 +52,7 @@ typedef struct Volume{
int nsamples;
int ng_cut_time; /*noise gate cut time, after last speech detected*/
int ng_noise_dur;
float ng_threshold;
MSBufferizer *buffer;
bool_t ea_active;
bool_t agc_enabled;
......@@ -75,6 +76,7 @@ static void volume_init(MSFilter *f){
v->noise_gate_enabled=FALSE;
v->ng_cut_time=100;/*milliseconds*/
v->ng_noise_dur=0;
v->ng_threshold=noise_thres;
#ifdef HAVE_SPEEXDSP
v->speex_pp=NULL;
#endif
......@@ -155,7 +157,7 @@ static void volume_echo_avoider_process(Volume *v){
static void volume_noise_gate_process(Volume *v , float energy, mblk_t *om){
int nsamples=((om->b_wptr-om->b_rptr)/2);
if ((energy/max_e)<v->thres){
if ((energy/max_e)<v->ng_threshold){
v->ng_noise_dur+=(nsamples*1000)/v->sample_rate;
if (v->ng_noise_dur>v->ng_cut_time){
v->target_gain=0;
......@@ -229,6 +231,12 @@ static int volume_enable_noise_gate(MSFilter *f, void *arg){
return 0;
}
static int volume_set_noise_gate_threshold(MSFilter *f, void *arg){
Volume *v=(Volume*)f->data;
v->ng_threshold=*(float*)arg;
return 0;
}
static inline int16_t saturate(float val){
return (val>32767) ? 32767 : ( (val<-32767) ? -32767 : val);
}
......@@ -337,6 +345,7 @@ static MSFilterMethod methods[]={
{ MS_FILTER_SET_SAMPLE_RATE, volume_set_sample_rate },
{ MS_VOLUME_ENABLE_AGC , volume_set_agc },
{ MS_VOLUME_ENABLE_NOISE_GATE, volume_enable_noise_gate},
{ MS_VOLUME_SET_NOISE_GATE_THRESHOLD, volume_set_noise_gate_threshold},
{ 0 , NULL }
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment