分类: C/C++
2017-07-28 17:22:41
本章概述:
1、优化了网络队列,提高网络丢包乱序包损情况下的回音消除质量,工具为Openwrt。
2、封装AGC接口解决speaker放大电路播放的声音能量太大,AEC无法精确消除,出现真声和回声都消除的问题
3、TestDemo已经包含了NS、VAD、AEC、AGC一整套调试成功的接口
流程图
备注:通过AGC增大Farend-0的增益,使得Farend-0与Farend-2+Near的能量相当,其中Farend-1大于Farend-2。
需解决难点:
1、硬件要求,低端设备视频音频加AEC后CPU(99%),声音一卡一卡,AEC没法运算。目前只做双向语音对讲,关闭设备视频录像,后期视频双向对讲需要高性能设备。
2、speaker为放大电路播放的数据能量太大,AEC无法精确消除,出现真声和回声都消除的现象。本章解决(通过AGC解决)!
3、在网络出现丢包乱序包损情况下的回音消除效果。本章解决(优化数据队列)
int echowebrtc_process(void *indata, int indata_len, short *outdata)
{
int frame_num = indata_len / FRAMESIZE;
if(0 < get_queue_data_count(queue_webrtc)) {
pthread_mutex_lock(&mutex);
queue_read(queue_webrtc,spk_c,BUFFSIZE);
memcpy(mic_c,indata,indata_len);
for(i = 0;i < BUFFSIZE/2;i++) {
mic_s[i] = (mic_c[i*2+1]<< 8) | (mic_c[i*2]&0xFF);
mic_f[i] = mic_s[i];
far_agc_s[i] = (spk_c[i*2+1]<< 8) | (spk_c[i*2]&0xFF);
spk_s[i] = (spk_c[i*2+1]<< 8) | (spk_c[i*2]&0xFF);
spk_f[i] = spk_s[i];
}
for(i = 0; i < frame_num; i ++) {
//AGC Farend
inMicLevel = micLevelOut;
outMicLevel = 0;
uint8_t saturationWarning;
WebRtcAgc_Process(handleAgc,far_agc_s+NN*i,NULL,NN,far_agc+NN*i,NULL,inMicLevel,&outMicLevel,0,&saturationWarning);
micLevelIn = outMicLevel;
fwrite(far_agc+NN*i,1,NN*2,fp_agc);
for(j = 0; j < NN; j++) {
spk_f[NN*i+j] = far_agc[NN*i+j];
}
//AEC Farend
fwrite(spk_s+NN*i,sizeof(short),NN,fp_fars);
EWebRtcAEC_BufferFarend(handleAEC,spk_f+NN*i,NN);
//fwrite(spk_f+NN*i,sizeof(float),NN,fp_far);
//AEC Process
//fwrite(mic_s+NN*i,sizeof(short),NN,fp_nears);
EWebRtcAEC_Process(handleAEC,mic_f+NN*i,1,out_f+NN*i,NN,aecDelay,0);
//fwrite(mic_f+NN*i,sizeof(float),NN,fp_near);
//Delay
//getAECDelayMetrics(spk_s+NN*i);
}
for(i = 0;i < BUFFSIZE/2;i++) {
//out_s[i] = out_f[i];
outdata[i] = out_f[i];
}
//fwrite(out_s,sizeof(short),BUFFSIZE/2,fp_out);
fwrite(outdata,sizeof(short),BUFFSIZE/2,fp_out);
pthread_mutex_unlock(&mutex);
return 0;
}
return -1;
}
AGC效果图
AGC&&AEC效果图
关注CSDN:http://blog.csdn.net/yuanchunsi/article/category/6850618