问题描述
我收到含有320样本分组PCM数据槽承插连接。声音的采样速率是每秒8000个样品。我用它做这样的事情:
I'm receiving PCM data trough socket connection in packets containing 320 samples. Sample rate of sound is 8000 samples per second. I am doing with it something like this:
int size = 160 * 2;//160;
int isinverse = 1;
kiss_fft_scalar zero;
memset(&zero,0,sizeof(zero));
kiss_fft_cpx fft_in[size];
kiss_fft_cpx fft_out[size];
kiss_fft_cpx fft_reconstructed[size];
kiss_fftr_cfg fft = kiss_fftr_alloc(size*2 ,0 ,0,0);
kiss_fftr_cfg ifft = kiss_fftr_alloc(size*2,isinverse,0,0);
for (int i = 0; i < size; i++) {
fft_in[i].r = zero;
fft_in[i].i = zero;
fft_out[i].r = zero;
fft_out[i].i = zero;
fft_reconstructed[i].r = zero;
fft_reconstructed[i].i = zero;
}
// got my data through socket connection
for (int i = 0; i < size; i++) {
// samples are type of short
fft_in[i].r = samples[i];
fft_in[i].i = zero;
fft_out[i].r = zero;
fft_out[i].i = zero;
}
kiss_fftr(fft, (kiss_fft_scalar*) fft_in, fft_out);
kiss_fftri(ifft, fft_out, (kiss_fft_scalar*)fft_reconstructed);
// lets normalize samples
for (int i = 0; i < size; i++) {
short* samples = (short*) bufTmp1;
samples[i] = rint(fft_reconstructed[i].r/(size*2));
}
在我填写的OpenAL缓冲区并播放它们。一切工作得很好,但我想这样做 kiss_fftr
和 kiss_fftri
之间的音频的一些过滤。出发点,我认为这是声音从时域转换到频域,但我真的不明白我从 kiss_fftr
函数接收什么样的数据。什么样的信息存储在每个那些复数,是什么它真正的部和虚部能告诉我有关的频率。我不知道哪个频率覆盖(什么频率范围)的 fft_out
- 哪些索引对应于频率
After that I fill OpenAL buffers and play them. Everything works just fine but I would like to do some filtering of audio between kiss_fftr
and kiss_fftri
. Starting point as I think for this is to convert sound from time domain to frequency domain, but I don't really understand what kind of data I'm receiving from kiss_fftr
function. What information is stored in each of those complex number, what its real and imaginary part can tell me about frequency. And I don't know which frequencies are covered (what frequency span) in fft_out
- which indexes corresponds to which frequencies.
我总新手信号处理和傅立叶变换主题。
I am total newbie in signal processing and Fourier transform topics.
任何帮助吗?
推荐答案
在用双脚跳成C实现之前,熟悉数字滤波器,ESP的。
Before you jump in with both feet into a C implementation, get familiar with digital filters, esp FIR filters.
您可以设计使用类似信号工具箱中的FIR滤波器。看看命令FIR1(简单),firls或雷米兹。或者,你也许可以通过网页来设计FIR滤波器。快速的Web搜索在线FIR滤波器设计发现(我没有用它,但它似乎使用了雷米兹或firpm命令中使用的等波纹设计)
You can design the FIR filter using something like GNU Octave's signal toolbox. Look at the command fir1(the simplest), firls, or remez. Alternately, you might be able to design a FIR filter through a web page. A quick web search for "online fir filter design" found this (I have not used it, but it appears to use the equiripple design used in the remez or firpm command )
尝试用直接卷积(不含FFT)算法实现第一次过滤器,看看速度是可以接受的 - 这是一个更容易的路径。如果你需要一个基于FFT的方法,还有在kissfft /工具/ kiss_fastfir.c文件的一个样本实现重叠保留。
Try implementing your filter first with a direct convolution (without FFTs) and see if the speed is acceptable -- that is an easier path. If you need an FFT-based approach, there is a sample implementation of overlap-save in the kissfft/tools/kiss_fastfir.c file.
这篇关于kiss_fftr的KissFFT输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!