Re: Question about PCM with 32-bit float
Reply #10 – 2022-07-28 20:20:59

Something to add, specific to your post:For example, if I compare a 32bit integer and a 32bit float file It is important to know how the two files are generated/converted/created. The generator must be able to handle 32-bit integer and float with full precision for a meaningful comparison. It is usually achieved by using 64-bit float internal math because it can handle all possible 32-bit integer and float values losslessly.If I compare them in DeltaWave DeltaWave's methodology is based on FFT, which means averaging a lot of samples. The "correlated null" value is not useful for what you want to understand. It is much easier and appropriate to look at a single value.https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_fround Change the code in the tutorial in this way:let a = Math.fround(9876543); let b = Math.fround(987654321); let c = Math.fround(9876543210); let d = Math.fround(16777216); let e = Math.fround(-16777211); let f = Math.fround(987.654321); ...and the results look like this:9876543 987654336 9876543488 16777216 -16777211 987.654296875 a: No difference, but this value is invalid for signed 24-bit integer which only has a range from -8388608 to 8388607. b: Error = 15 32-bit integer can losslessly represent this value, but 32-bit float can't because a fixed amount of bits are reserved for exponent in order to represent a huge dynamic range (about 1500dB for 32-bit float). c: Error = 278 9876543210 will clip or overflow when stored as 32-bit integer, so despite the larger error, float is still light years better than integer. When converting to integer, this value must be normalized/reduced to 2147483647 or smaller, so error will also be reduced proportionally. d: No difference, and 32-bit float can losslessly represent every integer value from -16777216 to 16777216 losslessly (25 bits) e: No difference, as an example that float can represent negative values in the same way as positive values. f: While there is some error, 32-bit float is still much more precise than integer, which will round to 988. So you can see that float is much more consistent when representing large and small values. 1500dB dynamic range is a waste for audio, but until generic hardware/software can use arbitrary mantissa/exponent bit assignment without performance penalty, it is a necessary compromise when using float. Some GPU/AI processors have more flexibility on floating point types with lower bit-depth (16-24) and different mantissa/exponent bit assignment though. Out of the processing chain, for a static file format, since 32-bit float will start to lose precision (compared to 32-bit integer) when the sample values are beyond +/-16777216, depends on the audio content, if a specific audio file mostly contains smaller values, float will have an advantage, otherwise 32-bit integer will have better numeric precision. For this reason, it is often recommended to normalize the audio file to somewhere between 0dBFS to -1dBFS when exporting to integer in order to optimize precision. You can use the program I made to check the distribution of sample values in your audio files, something DeltaWave won't do:https://hydrogenaud.io/index.php/topic,114816.msg1010860.html#msg1010860 The program won't tell you the bits are data or garbage, of course. It just shows the distribution.