0

I'm trying to do a Fourier Transform on audio file. So far I've managed to read the header of the file with the help of this answer. This is the output.

The audio format is 1 which means PCM and I should really easily be able to work with the data. However, this is what I can't figure out.

Is the data binary and I should convert it to float or something else that I can't understand?

genpfault
  • 51,148
  • 11
  • 85
  • 139
That Guy
  • 154
  • 2
  • 14

2 Answers2

1

Yes, it's binary. Specifically, it's signed 16-bit integers. You may want to convert it to float or double depending on your FFT needs.

L. Scott Johnson
  • 4,213
  • 2
  • 17
  • 28
0

I suggest you use a mono channel input audio file ... the sample you showed has two channels ( stereo ) which complicates the data slightly ... for a mono PCM file the structure is

two-bytes-sample-A  immediately followed by two-bytes-sample-B ... etc.

in PCM each such sample directly corresponds to a point on the analog audio curve as the microphone diaphragm (or your eardrum) wobbles ... paying attention to correct use of endianness of your data each of these samples will result in an integer using all 16 bits so the unsigned integers go from values of 0 up to (2^16 - 1) which is 0 to 65535 .... confirm your samples stay inside this range IF they are unsigned

Scott Stensland
  • 26,870
  • 12
  • 93
  • 104