Large Wav files
953238Aug 1 2012 — edited Aug 9 2012Hi,
I'm trying to open a large (3 gigabyte) wav file using
AudioInputStream audioStream = AudioSystem.getAudioInputStream(file)
The size of the file is returned as negative and it's impossible to read from the file using
bytesRead = audioStream.read(byteArray, 0, blockSize);
I've experience of unpacking wav files byte by byte (in C). I assume that this issue is being caused by the unsigned 32 bit integer giving the file size in the wav header being read by Java as a signed integer, which then of course exceeds the maximum value for an signed int and wraps to become a negative number.
Clearly the problem could be fixed in the part of Java which reads the actual wav file header with a few lines of code which read the size, convert to long, check it's > 0 and if it isn't, then add 2^32 (to the long, which won't wrap).
Has anyone found a simple work around ? My options seem to be either to work out how to fix the Java source myself (which I'm reluctant to dive into - life is short) or to write my own wav file reader, which will lose me a lot of the friendly functionality of javax.sound and require me to rewrite a lot of existing code.
Many thanks for any assistance.
Douglas.