加速框架vDSP,FFT成帧 [英] Accelerate framework vDSP, FFT framing

查看:288
本文介绍了加速框架vDSP,FFT成帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Apple的vDSP在记录的音频文件上实现FFT计算(假设它是单声道PCM)。

I'm trying to implement FFT calculation, using Apple's vDSP, on a recorded audio file (let's assume it's a mono PCM).

在这里进行研究,发现以下主题非常有用:

I've did a research here and I've found following topics quite useful:

例如,我们将FFT配置为frame_size N = 1024个样本,log2n = 10:

For example, we configured FFT with frame_size N = 1024 samples, log2n=10:

m_setupReal = vDSP_create_fftsetup(LOG_2N, FFT_RADIX2);

// allocate space for a hamming window
m_hammingWindow = (float *) malloc(sizeof(float) * N);

// generate the window values and store them in the hamming window buffer
vDSP_hamm_window(m_hammingWindow, N, vDSP_HANN_NORM);

代码中的某个位置:

vDSP_vmul(dataFrame, 1, m_hammingWindow, 1, dataFrame, 1, N);

vDSP_ctoz((COMPLEX *)dataFrame, 2, &(m_splitComplex), 1, nOver2);

// Do real->complex forward FFT
vDSP_fft_zrip(m_setupReal, &(m_splitComplex), 1, LOG_2N, kFFTDirection_Forward);

以我对FFT使用的理解,我现在缺少的是如何获得完整的频谱假设一个大音频文件总共有12800个样本。

What I'm missing right now, in my understanding of FFT usage, is how to get complete spectrum of a large audio file, let's assume 12800 samples in total.

Q:
我是否需要将原始数据拆分为大小为1024个样本的帧(〜12800/1024 = 13帧),然后分别对每个帧执行FFT,然后以某种方式将13个FFT结果的平均值进行平均?如果是正确的假设,那么如何进行平均?

Q: Do I need to split raw data into frames with size 1024 samples (~ 12800 / 1024 = 13 frames), then perform FFT on each frame separately and then, somehow, average 13 FFTs results into resulting spectrum? If it's correct assumption, then how to perform averaging?

我将非常感谢您的帮助。

I'd really appreciate any help.

推荐答案

除非您有统计上稳定的信号,否则您不想对频谱进行平均。如果它像语音或音乐一样随时间变化,那么您实际上就具有3D数据集:时间与频率相对于幅度,可以将其绘制为频谱图瀑布图

You don't want to average the spectra, unless you have a statistically stationary signal. If it's something time-varying like speech or music, then you effectively have a 3D data set: time versus frequency versus magnitude, which you can plot as a spectrogram or waterfall plot.

还要注意,通常的做法是重叠连续的窗口,以在时间轴上获得更高的分辨率,因此您的第一个块可能是样本0..1023,然后是具有50%重叠的第二个区块将是512..1535,依此类推。

Note also that it is common practice to overlap successive windows, to gain more resolution in the time axis, so your first block might be samples 0..1023 and then the second block with 50% overlap would be 512..1535, etc.

这篇关于加速框架vDSP,FFT成帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆