0

Ok so in audio files we have samples that can come in 8-bit (byte), 16-bit (short), 32-bit (int, float), and 64 bit (double). My issue is with the 32-bit how can I determine from 4 bytes if I am looking at an integer or a float. Right now I am reading in all values as floats and hoping for the best. Just for simplicity lets assume little endian.

I should also note from everything I have read the floating point values may or may not be normalized so even floating point values can exceed 1 and -1.

SkidRunner
  • 813
  • 8
  • 12
  • That depends entirely on what sort of audio file you have. Usually something in the specification for the file format or the metadata in the file will say what the format is. – greg-449 Apr 15 '16 at 19:05
  • Most wav files I deal with are little-endian, 16-bit encoding, signed, shorts, encoded at 44100 fps. Most of the internal processing I do with sound data is as floats between -1 and 1 (normalized) where exceeding that range results in horrible distortion. The "density" of values in the normal range, for floats, is quite high and has been found to be sufficient for high quality audio. – Phil Freihofner Apr 15 '16 at 19:10
  • @greg-449 I am trying to support several audio formats what I have found is I could try looking for the mantissa or fractional part with a bitwise operation '(sample & 0x001FFFFF) == 0' this would return if the fractional part exists. I was just hoping for a better solution. – SkidRunner Apr 15 '16 at 21:58

0 Answers0