webrtc 低通滤波器

发布时间 2023-11-07 11:18:19作者: balder_m

 

#include "low_pass_filter.h"

 

 

    double prev_output= 0.0;
    double prev_input = 0.0;

 

 

//去噪
WebRtcNsx_Process(webrtc_nsx, &g_aecmAudio, 1,&g_ns);

if(WebRtcAgc_Process(webrtc_agc,&g_ns , 1, 160, &pBuff, in_mic_level, &out_mic_level, echo, &saturation_warning) != 0)
LOGE("WebRtcAgc_Process fail\n");

//LOGE("fd =%d nPackSize=%d",fd3,write(fd3,(char*)pBuff,160));
// if (fp1 != NULL)
//fwrite(g_ns, sizeof(short), nLen, fp1);
short low_pass_buff[160] = {0};
//double prev_output;
prev_output = 0.0;


double cutoff_freq = 2000.0; // 2 kHz
double sample_rate = 16000.0;
for (int i = 0; i < nLen; ++i) {
double tmp = filter(pBuff[i], prev_output, prev_input, cutoff_freq,
sample_rate);
low_pass_buff[i] = (tmp);
prev_output = tmp;
prev_input = pBuff[i];
}
// 音频压缩
int nEncLen = g_speex.Encoder(pBuff,m_speexEncBuf);