我用的是 DSPF_sp_fftSPxSP 函数,参数说明如下:
void DSPF_sp_fftSPxSP(int N, float *ptr_x, float *ptr_w, float *ptr_y, unsigned char *brev, int n_min, int offset, int n_max);
/**
* The benchmark performs a mixed radix forwards fft.
*
* @param N length of FFT in complex samples
* @param ptr_x pointer to complex data input
* @param ptr_w pointer to complex twiddle factor
* @param ptr_y pointer to complex output data
* @param brev pointer to bit reverse table containing 64 entries
* @param n_min should be 4 if N can be represented as Power of 4 else, n_min should be 2
* @param offset index in complex samples of sub-fft from start of main fft
* @param n_max size of main fft in complex samples
*
* @par Algorithm:
* DSPF_sp_fftSPxSP_cn.c is the natural C equivalent of the optimized linear assembly code without
* restrictions. Note that the linear assembly code is optimized and restrictions may
* apply.
*
* @par Assumptions:
* N needs to be power of 2 <BR>
* 8 <= N <= 131072 <BR>
* Arrays pointed by ptr_x, ptr_w, and ptr_y should not overlap <BR>
* Arrays pointed by ptr_x, ptr_w, and ptr_y should align on the double words boundary <BR>
*
* @par Implementation Notes:
* @b Interruptibility: The code is interrupt-tolerant but not interruptible. <BR>
* @b Endian Support: The code supports both big and little endian modes. <BR>
*
*/
最近打算用TI的FFT替换speex中的spx_fft()函数,提升运行速度,查看了资料发现 DSPF_sp_fftSPxSP 函数只能计算2的指数次幂的数据长度,
但是我设备是32khz采样率20ms一帧,数据长度是640个采样点计算一次,该怎么计算呢?
如果我将N设置为640,
DSPF_sp_fftSPxSP(N, in_sp, www_sp, out_sp, brev, 2,0, N);
计算出来的数据和MATLAB仿真出来的数据不一致(matlab数据长度设置为640)
如果我将N设置为1024,640至1024多出来的数据填0,和matlab直接算640个点的结果不一致,却和matlab仿真出来的数据一致(matlab数据长度设置为1024,640至1024多出来的数据填0)。
但是这样分频的话会影响我程序里面计算,所以有没有别的办法可以计算任意长度的FFT,比如640的数据点数?
Shine:
这个是函数要求的,补0确实会影响精度,如果要用dsplib库的话,没有别的办法计算任意长度的FFT。