1

I will analyse a wav file server side with an fft algorithm.

When read the pcm data from the wav file i get a Float32Array, but i think for a fft calculation i need an Array with Float32Arrays inside. Each of this array represent a sample with a specific size (1024, 2048 ...) is this correct?

How can i perform a fft calculation on pcm data from a wav audio file? The length of the Float32Array that i get when i read the pcm data form the wav file is 219036.

[
[0.5,0.5,-0.5,-0.5],
[0.3,0.3,-0.3,-0.3]
]

I will do this in node.js

Thank you for all thoughts

UPDATE:

Expected pcm data looks like this:

[
 [0.5,0.5,-0.5,-0.5],
 [0.3,0.3,-0.3,-0.3]
]

I get this pcm data when i read the wav file:(All in one array)

[
 0.5,0.5,-0.5,-0.5,0.3,0.3,-0.3,-0.3
]
8
  • 1
    You want to create a spectrogram? Which FFT library are you trying to use? Apr 8, 2017 at 14:01
  • I will calculate only the FFT of a wav file, my problem is i didn't understand why the pcm data in the wav file all in one array not by samples. I only know pcm data like this in the question (I updated the question). I will use this library fft-js and this for decode the wav file wav-decoder.
    – Aron
    Apr 8, 2017 at 14:10
  • 1
    Why did you expect two arrays there? Do you want one for left/right channel? The library probably gives you an interleaved format. So a[i*2] is the first channel, a[i*2+1] is the second channel. Note that you normally don't take the FFT of too long audio, it's not useful. You take FFT of a short part of it. Apr 8, 2017 at 14:20
  • When i analyse the realtime mic in put i get an array with n values (2048) every time when a sample is done, then i analyse this array and get the frequency data (result is an fft with a window size of 1024). But on this pcm data i get only one big array. I didn't understand on which part of this pcm data i need to perform the fft calculation? Yes i know this about the short part, this is exactly i will do
    – Aron
    Apr 8, 2017 at 14:30
  • 4
    Take the first 2048 values from the array and analyze those, then the next 2048, and so on. This is called short-time fourier transform (STFT). You might want to have those windows overlapping (e.g. take the first 2048 values, then jump to value 1024 and take the next 2048 values from there), but you don't have to do that. Apr 8, 2017 at 14:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.