与FFTW实时冲激响应卷积 - 结果听起来像IR是对称的 [英] Real-time impulse response convolution with FFTW -- result sounds like IR is symmetrical

查看:167
本文介绍了与FFTW实时冲激响应卷积 - 结果听起来像IR是对称的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关研究目的,我建立在C实时卷积混响引擎++使用FFTW(和PortAudio的声音交货)与卷积重叠相加的方法。大部分是工作,而是一个非常奇特的效果出现。虽然我不明白为什么,听起来非常仿佛脉冲响应变得对称:是什么 H [N] 变成 H [N] + H [-n] 。有谁知道,如果在我在下面描述的方式进行FFT会产生这样的效果?

For research purposes I am building a real-time reverb convolution engine in C++ using FFTW (and PortAudio for the sound delivery) with the overlap-add method for convolution. Most of it is working, but a very peculiar effect occurs. Though I can't see why, it sounds very much as if the impulse response becomes symmetrical: what was h[n] becomes h[n] + h[-n]. Does anyone know if performing FFT in the way I describe below would have this effect?

基本上,我的过程如下:

Basically, my process is as follows:


  • ^ h ,脉冲响应 M 样本长

  • X ,健全 N 样本长

  • FFT_SIZE ,一个分区大小/窗口大小

  • h, an impulse response m samples long
  • x, a sound n samples long
  • FFT_SIZE, a partition size/window size

N'GT;米 3 ISH的一个因素,但 FFT_SIZE 是(目前1024)小得多

n > m by a factor of 3 ish but FFT_SIZE is much smaller (1024 at the moment)

我分裂 X FFT_SIZE 长度的部分。因为我将卷积与 ^ h ,我复制每一个进入长度的0填充缓冲 N + M每个窗口 - 1 样本,并执行正向FFT,保存得到复数排列。 (我有 N / FFT_SIZE 复杂的阵列。)现在我使用矩形开窗没有重叠,将实施海明能否改善的东西,一旦我解决这个问题。

I split x into portions of FFT_SIZE length. Because I will convolve each window with h, I copy each one into a 0-padded buffer of length n+m - 1 samples, and perform a forward FFT, saving the resulting complex array. (I have n/FFT_SIZE complex arrays.) For now I am using rectangular windowing with no overlap, will implement Hamming if it improves things once I resolve this issue.

我进一步执行 h的单前锋FFT 后0填充,以长度 N + M - 1 ,和相同尺寸的这种单复数排列存储作为其他

I furthermore perform a single forward FFT of h after 0-padding to length n+m - 1, and store this single complex array of same size as the others.

PortAudio最喜欢的音频引擎调用回调函数来填充缓冲退出与定期声音数据。在我的回调(这由设计要求 FFT_SIZE 音频样本,我选择了复杂的阵列重新$ P $每次(psenting在下一个窗口中,因为一个回调调用对应于同样的声音长度为FFT一个窗口)。

PortAudio like most audio engines invokes callbacks to fill a buffer out with sound data at regular intervals. In my callback (which by design requests FFT_SIZE samples of audio, I select the complex array representing the next window each time (since one callback invocation corresponds to same sound length as one window for FFT).

我执行此数组由我FFT-ING ^ h 提出的一个逐点相乘,并进行IFFT。产生的声音缓冲区 N + M-1 长,比 FFT_SIZE 大很多,所以我只复制开始进退出缓冲,其余添加到重叠/进行缓冲进缓冲区的开始移动到退出(所以退出现在包含的新IFFT'd数据的一个窗口的身价加入到$ p $的一个窗口的价值pviously计算衰减尾)

I perform pointwise multiplication of this array with the one I made by FFT-ing h, and perform IFFT. Resulting sound buffer is n+m-1 long, much bigger than FFT_SIZE, so I copy only the beginning into the out buffer and add the rest to a overlap/carry buffer (which accumulates reverb tail sound with each callback invocation) after moving the beginning of the carry buffer to out (so out now contains one window's worth of new IFFT'd data added to one window's worth of previously calculated decay tail).

就像我之前提到的,听起来莫名其妙的脉冲响应没有被正确FFT'd,并导致行为,如果它是对称的 - 反转,然后添加到自身。我不知道我做错了,但我不能看到这种效果可以通过我的承载问题产生 - !但如果我是,我会很高兴地发现的bug

Like I mentioned before, it sounds like somehow the impulse response is not being FFT'd correctly, and is resulting in behaving as if it was symmetrical -- reversed and then added to itself. I'm not sure what I'm doing wrong, but I can't see how this effect can be produced by a problem with my carrying -- though if I am, i'd be glad to have found the bug!

我最好的猜测是,不知怎的,我应该执行 ^ h 窗口为好。然而,根据我阅读文献,你只是卷积 X 与整个 ^ h 的每个窗口,做进。这是错的吧?

My best guess is that somehow I'm supposed to perform windowing of has well. However, based on the literature I've read, you just convolve each window of x with the whole h and do the carry. Is this wrong perhaps?

感谢您的帮助!

推荐答案

您算术时逐点乘以2 FFT载体似乎是错误的。复矢量乘法具有考虑到实部和虚部之间的叉积。例如重新= RE1 * RE2 - IM1 * IM2; IM = RE1 * IM2 + RE2 * IM1等。

Your arithmetic when point-wise multiplying the 2 FFT vectors appears to be wrong. Complex vector multiplication has to take into account the cross product between the real and imaginary components. e.g. re = re1*re2 - im1*im2; im = re1*im2 + re2*im1 , etc.

这篇关于与FFTW实时冲激响应卷积 - 结果听起来像IR是对称的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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