I need to know whether a ".wav" of 8bits, is signed or unsigned PCM, by only reading file. I cannot use "javax.sound.sampled.*" or AudioSystem libraries.
In the wav File, 8-bit samples are stored as unsigned bytes, ranging from 0 to 255. The 16-bit samples are stored as signed integers in 2's-complement.
8 bit (or lower) WAV files are always unsigned. 9 bit or higher are always signed:
Each sample is contained in an integer i. The size of i is the smallest number of bytes required to contain the specified sample size. The least significant byte is stored first. The bits that represent the sample amplitude are stored in the most significant bits of i, and the remaining bits are set to zero.
For example, if the sample size (recorded in nBitsPerSample) is 12 bits, then each sample is stored in a two-byte integer. The least significant four bits of the first (least significant) byte is set to zero.
The data format and maximum and minimums values for PCM waveform samples of various sizes are as follows:
Multimedia Programming Interface and Data Specifications 1.0 - IBM/Microsoft, August 1991
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With