I am having an issue on writing a wav file with int16 data. For testing I made a file with sample [0]=-32768 then each sample increments on up to sample[65536] = 32767.
The issue is values greater than 16384 (+0.5f) are written one bit value too low.
sample[49152]=16384 (0.5f)
sample[49153]= should be 16385 (0.500031f) but is 16384 (0.5f)
sample[49154]= should be 16386 (0.500061f) but is 16385 (0.500031f)
The attached zip has a console app that reads the input file and compares it to what the values should be (in floats). It then writes the data from the file into a second file and compares it to what it should be.
I guess that make sense, surprising to me that all the error shows up at >0.5f. That being said, I should be able to add 1/(0x7fff) to sample for values > 0.5f before writing it to file and get the output values back. At this point I am only messing with the metadata.