2
$\begingroup$

From discussions all over the internet, I understand that in a 512 sample point fft, only the first 256 contain relevant information provided that my signal is real. The other half contains complex conjugates of the first half. I base my question on this discussion at stack exchange.

I'm trying to plot the fft of a wav file. I used 2 files - one wav file containing some music and another that was generated by scrip to play at 440Hz. The fft plot of the 2nd (440hz signal) showed 2 peaks - one at 440hz and another at the other end of the plot. This was expected. However, plot of the music wav file was asymmetric. How can that be? Asymetric plot

I used the file onclassical_demo_elysium_anonymous-elysium_the-young-false-man_small-version_live-and_restored found here. Scipy did not parse it properly first and I had to strip the meta tags using audacity before I could get it working.

I used print and I got this for the 440hz tone :

[ 203395.00000000  +0.j          203395.08226712 -57.78564066j
203395.32901382-115.57039787j ...,  203395.74007235+173.35334037j
203395.32901385+115.57039784j  203395.08226713 +57.78564063j]

For the music file, I got this :

[[ 2.+0.j -4.+0.j]
[-1.+0.j -7.+0.j]
[ 0.+0.j -2.+0.j]
..., 
[ 0.+0.j -6.+0.j]
[ 0.+0.j -2.+0.j]
[ 1.+0.j -1.+0.j]]

I don't think any of them are symmetrical! Or else the first and last values should coincide at least in the real part right?

And just for the sake of it, the 440hz signal plot :

The 440hz signal plot

I tried plotting abs(fft) - still asymmetrical. Also, why is the plot having both blue and green colors - real and complex parts?

$\endgroup$
  • $\begingroup$ The first image in the post is the source signal, right? Because it looks so (check your code?). $\endgroup$ – werediver Apr 19 '14 at 12:15
  • $\begingroup$ First image in the post is the source (from the music file), the second one is 440hz tone. $\endgroup$ – Kevin Martin Jose Apr 19 '14 at 12:25
  • $\begingroup$ Considering the first value of FFT output, it's constant component (mean) and present only in positive frequencies half. Minor difference in the other components can be considered as a computational error (in the case you're expecting perfectly equal values). $\endgroup$ – werediver Apr 19 '14 at 12:38
  • $\begingroup$ could you show a plot of how asymmetrical it is? Are we talking about a 50% difference from the expected symmetry? I see that the music file you are using was understood by your program as complex numbers, all with imaginary part zero. Maybe the FFT routine is having floating point roundoff errors and that is where the assymetry is coming from $\endgroup$ – bone Apr 19 '14 at 16:22
  • $\begingroup$ The samples from bin 22500 onwards should have been a mirror of those till 22500. Looking at the plot I can only say that its quite asymmetrical - or 100% asymmetrical since I do not see any cluster to be similar to the first half. $\endgroup$ – Kevin Martin Jose Apr 19 '14 at 16:58
5
$\begingroup$

Using the wav version of the file you linked to I performed an fft in matlab and got:

First 3 terms:

 left channel       right channel
-1.1594 + 0.0000i  -1.8450 + 0.0000i
-0.4186 - 1.0013i  -0.2851 - 1.7655i
 0.5507 - 0.7589i   1.0478 - 0.4655i

Last 3 terms:

 left channel       right channel
 0.7388 - 0.3032i   0.4740 - 0.6654i
 0.5507 + 0.7589i   1.0478 + 0.4655i
-0.4186 + 1.0013i  -0.2851 + 1.7655i

Looks conjugate symmetrical

I wonder if you are processing the left and right channels at the same time and it is thinking it is a 2d signal or a complex valued signal.

The only way you get an asymmetric fft result is if the signal is complex.

$\endgroup$
  • $\begingroup$ That explains it. I didn't consider that there are 2 channels and I was unaware the it is circular conjugate. $\endgroup$ – Kevin Martin Jose Apr 20 '14 at 8:09
  • $\begingroup$ So the blue lines are one channel and the green ones the other? $\endgroup$ – Kevin Martin Jose Apr 20 '14 at 8:10
  • $\begingroup$ When I plot both channels they look pretty much the same as each other, with the same amplitude and a shape like the blue series in your chart. However, it says there are ~350000 samples. $\endgroup$ – geometrikal Apr 20 '14 at 9:37
  • $\begingroup$ Oh. In the first graph, there are 35000 samples as well. But Instead of plotting amplitude to sample, I plotted amplitude to frequency. This stackexchange discussion helped me do it $\endgroup$ – Kevin Martin Jose Apr 20 '14 at 10:12
  • $\begingroup$ Amplitude to freq or do you mean amplitude to time? Did you get it working btw? $\endgroup$ – geometrikal Apr 21 '14 at 1:06
2
$\begingroup$

FFT results of strictly real input are circularly conjugate symmetric around the first bin (bin 0). Thus the complex conjugate of the last bin should be equal to the second bin (bin 1), not the first bin.

$\endgroup$
  • $\begingroup$ Want to vote up but that required 15 Rep :) $\endgroup$ – Kevin Martin Jose Apr 20 '14 at 8:09

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.