8
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ I'm not clear as to what exactly you mean by: 1) some form of reflection at fs/4 and 2) striping effect... Could you perhaps provide a figure showing your spectrogram/fft plot pointing out what you mean by these? I can assume as to what you mean, but that wouldn't be very helpful. $\endgroup$ – Lorem Ipsum Sep 21 '11 at 16:47
  • $\begingroup$ I am with yoda in failing to understand your description, but mirroring bin 0 to n-1 definitely sounds incorrect. Bin 0 represents DC and should not be mirrored anywhere. If n is even, then Bin n/2 also needs special handling. Also, I would advise against calling a 1024-point IFFT an order-10 IFFT as this terminology is more likely to confuse than to help. $\endgroup$ – Dilip Sarwate Sep 21 '11 at 17:03
  • $\begingroup$ @yoda: Updated. $\endgroup$ – Goz Sep 21 '11 at 17:10
  • $\begingroup$ @Dilip Sarwate: Apologies, its very hard to describe and even harder to see. $\endgroup$ – Goz Sep 21 '11 at 17:11
  • $\begingroup$ @Goz what are the axes? $\endgroup$ – Lorem Ipsum Sep 21 '11 at 17:14
4
$\begingroup$

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.

$\endgroup$
3
$\begingroup$

Your [0] index is the DC component and should not be mirrored. The reflection point should be (N/2)+1

$\endgroup$
1
$\begingroup$

Let's say you have a 1024 point real sequence. A complex FFT turns that into 1024 complex numbers. However X[0] (DC) and X[512] Nyuist are real and X[1]..X[511] are conjugate symmetric so the whole spectrum can still be represented with 1024 numbers (2 reals and 511 complex). Let's say you have a half sided spectrum X[0]...x[512] and want to create the conjugate symmetric version of it Y[0] ... Y[1023]. Do the following

Y[0] = X[0], Y[1] = X[1] .... Y[512] = X[512];
Y[513] = conjugate(X[511]), Y[514] = conjugate(X[510]) ... Y[1023] = conjugate(X[1])

If you use Matlab you need to add "1" to all indices as Matlab starts counting at 1 (not at 0).

$\endgroup$
0
$\begingroup$

The reflection is normal: It's called aliasing, or frequency folding, and it happens when the signal you're sampling exceeds what's called the Nyquist frequency, which happens to be half your sampling frequency. Ideally, you want a sampling frequency of at least twice the frequency of the signal you're sampling, for precisely this reason.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.