Monday 29 February 2016

fourier transform - Complex conjugate and IFFT


I asked a question over on stack overflow.


I'm having a slight problem however. As suggested by Paul R I am mirroring my lower $n/2$ bins into the upper $n/2$ bins.


I have a few questions however.



  • I'm assuming $n$ is $2^{fftOrder}$? Thus for an order 10 IFFT I would be mirroring the bottom 512 frequency bins in to the top 512? This would also produce me 1024 real samples in the end?

  • When mirroring does this mean that bin 0 would go to bin $n - 1$, bin 1 to bin $n - 2$ and so on?

  • I appear to be getting some form of reflection at a quarter of my sampling frequency? This means that the top half of my frequency range is actually appearing over the bottom half. Has anyone any ideas why?

  • Does anyone have any idea why I am getting a striping effect where I get 512 samples of one magnitude and the next 512 of a different? (This "could" be where my mirroring is coming from)



I think thats it for now. Any help would be hugely helpful!!


Edit: Giving you an image of the reflection will be near enough impossible as its very hard to see! Basically I'm sampling at 22 kHz and getting nothing but "noise" above 11 kHz. What "ought" (though obviously I'm doing something wrong) to be above 11 kHz seems to get reflected down from 11 kHz to 0. Its very odd.


As for the image of the stripes they can be seen here


Each stripe, I believe, is 512 samples wide.



Answer



I'm not sure what you're getting at with "reflection" or "striping," but you want to duplicate your data points such that the frequency-domain signal (the input to the IFFT) is conjugate symmetric. That means, for $N$ even:


$$ X[k] = X^*[N-k], k = 1, 2, \ldots, \frac{N}{2}-1 $$


Note that $k$ is zero-based; the first element in the vector is $X[0]$. The above indicates that you do not duplicate the zeroth and $\frac{N}{2}$-th elements in the input vector. This relationship is based on the periodicity of the discrete Fourier transform; the first half of the frequency-domain vector corresponds to "positive" frequencies covering the angular frequency range from $0$ to $\frac{(N-1)\pi}{N}$. The second half covers from $\pi$ to $\frac{(N-1)2\pi}{N}$, which, taking advantage of the $2\pi$ periodicity in the frequency domain, is equivalent to $-\pi$ to $\frac{-2\pi}{N}$. In order for the frequency-domain vector to have conjugate symmetry, then it can be easily shown that the above relationship must be true.


Speaking to your original goal of converting a spectrogram into an audio signal that sounds meaningful, there's no guarantee that what you get out will be in any way pleasing. As was pointed out on Stack Overflow, the spectrogram has no phase information; the method suggested there assumes the phase of each frequency-domain bin is zero (so the conjugate operation shown above is superfluous). While the human ear isn't terribly sensitive to phase distortion in audio, you might have to do something else depending upon exactly what you're hoping to achieve.


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...