2

I am trying to write a program that will create 24 bit wav files using java. The java sound api does not support 24 bit audio so I am trying to write the file from scratch. This started out as a casual interest but it has become an epic quest of bits, bytes, signs and chunks.

Does a 24bit wav file's data chunk have signed or unsigned bytes?

Java's lack of unsigned bytes is frustrating. I have read that bit masked integers can be used to represent unsigned bytes but I wonder how that will be represented in the final output to file.

Sorry to diverge... my question is "Does a 24bit wav file's data chunk have signed or unsigned bytes?"

Either way I am going to have to figure out this signed/unsigned business but I can't find an answer regarding the data chunk in the references I have found.

Dave B.
  • 31
  • 1
  • 2
  • A .wav file is just a container. The actual signedness of the sample data is up to whatever codec was used to store the audio. – Marc B Mar 31 '11 at 19:12

2 Answers2

2

I can also confirm that 24 bit data in WAV files is signed (when the data is stored in the WAVE_FORMAT_PCM format). More generally, WAVE_FORMAT_PCM data is always signed EXCEPT when it is 8-bits per sample.

garlon4
  • 1,162
  • 10
  • 14
  • Thanks for the reply. I had a feeling that was the case but I couldn't find any specific confirmation. Most of the information I found on the web was regarding 16 bit audio in waves. – Dave B. Mar 31 '11 at 19:52
1

According to this (and my own personal experience) Microsoft WAVE files use 2's-complement signed integers to represent PCM samples larger than 8 bits. By default, the byte-order of those integers is little-endian.

You can use soxi from the SoX package to verify this on your own test files (you do have some, right?).

Please note that WAVE files can also hold audio formats other than plain PCM.

thkala
  • 84,049
  • 23
  • 157
  • 201
  • Thanks, that tool looks to be very useful. I looked at that very web page yesterday a few times but I missed that link somehow. – Dave B. Mar 31 '11 at 19:50
  • The link is dead. Here is the link to archive: https://web.archive.org/web/20110720050155/https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ – quartzsaber Aug 09 '21 at 09:29