0

I am working on a project with audio files. I read a file and parse it. I compare my parsed values with other sources and everything seems fine. (FYI : wav file with 16 bits per sample, 44.100 Hz and 7211 sample points.)

Since my every data point is defined with 16 bits I expect my value range as [-65536, +65536]. I get -4765 as minimum and 5190 as maximum from the values I read.

But when I perform the same operation in MATLAB I get -0.07270813 and 0.079193115 respectively. This is not a big problem because it seems that MATLAB seems normalizing my values within range [-1, +1]. When I plot I get the same figure.

But when I take FFT from both applications (I am using Lomont FFT) result differ greatly and I am not sure what is wrong with my code. Lomont seems fine but the results are inconsistent.

Is this difference normal, or should I use another algorithm for this spesific operation. Can anyone suggest a better FFT algorithm (I already tried NAudio, Exocortex etc) in C# to get compliant result with MATLAB. (I suppose that their result are correct.) or any advice or suggestions on this difference?

My plots : My plot

MATLAB plots: MATLAB plot

user3021830
  • 2,784
  • 2
  • 22
  • 43
  • 1
    The first thing I notice is that your MATLAB plot is symmetric (i.e. you're also plotting the 'negative' frequencies). You should discard the second half of your data set. A bit more background: http://blogs.mathworks.com/steve/2010/05/27/negative-frequencies/ – Tom May 06 '16 at 12:53
  • Yes you are right. But even if I use abs() function the values are different. Any comments on cause of the different values maybe? – user3021830 May 06 '16 at 13:02
  • 2
    Tom doesn't mean using abs(), he means that you should only be looking at the first half of the fft output in matlab, i.e. `x = fft(signal); plot(x(1:end/2));` - it looks like they will line up pretty well if you do that. – Hugh Nolan May 06 '16 at 13:05
  • I see your point. The FFT of MATLAB seems mirrored from the mid-point. And you suggest that if I take the positive half portion I will get the same results. I will try that. – user3021830 May 06 '16 at 13:22

0 Answers0