我还是把我的代码发上来(完整代码见我传上的文档)
滤波器系数(这里给的是7介的我用的是127介的,太长了占地方,就用7介示意了 是S16Q15格式)
#if (FILTER == LPF_7_TAP)
// Fs = 48KHz, Fc = 2KHz, Hamming window 7 taps
Int16 coeffs[LPF_7_TAP] = {
0x00c5, 0x0328, 0x081f, 0x0aab, 0x081f, 0x0328, 0x00c5
};
对滤波器做FFT变换函数
/* FFT_Coeffs: Calculate and store the FFT of the filter coefficients */
void FFT_Coeffs()
{
Uint16 i, fft_flag, scale_flag, out_sel;
Int32 *scratch, *data_br, *coeffs_fft, coeffSum;
scratch = scratch_buf;
data_br = data_br_buf;
coeffs_fft = coeffs_fft_buf;
// put coeffs into re|im 32-bit words
// zero-pad to FFT_LENGTH
coeffSum = 0; // make sure sum <= 1.0 for COLA properties
for(i=0; i
{
if(i
{
scratch= ((Int32)coeffs<<16);
coeffSum += coeffs;
}
else
{
scratch= 0;
}
}
// FFT and store in coeffs_fft[]
fft_flag = FFT_FLAG;
//scale_flag = NOSCALE_FLAG; //why is this necessary
scale_falg = SCALE_FLAG;
hwafft_br(scratch, data_br, FFT_LENGTH); // bit-reverse zero-padded coefficients //位倒序
out_sel = (*Hwafft_Func)(data_br, coeffs_fft, fft_flag, scale_flag); // perform FFT //这个函数是TI写好的硬件FFT函数 if(out_sel == OUT_SEL_DATA)
{
buff_copy32(data_br, coeffs_fft, FFT_LENGTH);
}
}
//对输入信号做l滤波
/* FFT_Filter:
* FFT the current window of samples
* Complex Multiply FFT output with FFT of filter coefficients
* (Multiplication in Frequency Domain = Convolution in Time Domain
* IFFT Complex Product to obtain filtered window plus ringing
*/</