Strange wav file format


#1

It seems that Adobe After Effect take some liberty with the wav file format.

The Juce git version a983bb1300e6ade0e475d163dc035aa61cde28a2 (31 Aug 2009 160852)
can parse Adobe After Effect wav. Avcodec, avformat, VLC mediaplayer can parse them too, but the current Juce git trunk cannot.

When I save a simple uncompressed PCM S16 (araw) 48000khz 16bit wav file,
The header in hexadecimal editor look like this:

'R', 'I', 'F', 'F', 0xF8, 0xFF, 0xFF, 0xFF, 'W', 'A', 'V', 'E', 'f', 'm', 't', 0x20...

I’m not a specialist of wav file format but it seems that file length is set to -8 in little endian !!!
In last Juce git trunk code, WavAudioFormatReader constructor
compute len to -8 and end to 0. So the further while loop exit directly without computing frequency and AudioFormat::createReaderFor return nullptr.

Can you do something to support this again ?
Thanks


#2

Yeesh, nasty. Looks like they’ve just bodged the value so that it’s permanently set to the largest possible value. Bunch of hackers!

But, in the latest code (modules branch) that I’m looking at, it does this:

else if (firstChunkType == chunkName ("RIFF")) { len = (uint64) (uint32) input->readInt(); end = input->getPosition() + len;

…so len = 0xfffffff8, and end = 0x100000000, which is ok, right?


#3

yes len is 0xfffffffffffffff8
but end is 0x0 instead of 0x100000000
(signed unsigned implicit cast?)

I’m using Visual Studio Express 2008 on WinXP 32.
the parsing fail also on Visual Studio 2008 win64 on win7 too.
With Juce current git master code.
(I do not know how to get git module branch, but this code block seem to be the same).


#4

Are you looking at the same code as me?

I deliberately wrote the (uint64) (uint32) cast so that it wouldn’t sign-extend it. I don’t see how it could do what you’re suggesting…


#5

the last time I checked, the master branch did not have this fix (about a month ago, see http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=6507&p=43904#p43904)

@alex:
just copy the line

into the corresponding position of your juce_WavAudioFormat.cpp, or try switching to the modules branch with the git commands jules proposed here: http://www.rawmaterialsoftware.com/viewtopic.php?f=12&t=7660#p43290

Be prepared for some minor code changes if you switch to the modules layout, but in my case the migration turned out to be surprisingly easy for such a big structural change of the JUCE internals.


#6

Thanks Steffen, sorry for the cross posting, this fix is not merged in the git master.

Jules, I’ve didn’t see the cast difference of your code, sorry for that.
It’s fix my bug. Thanks !


#7

Apologies for digging up this post, but I wanted to simply note that JUCE does not support the following WAV file formats, in case other JUCE coders are running into any kind of trouble when loading a wave file:

[list]

For more information:
http://wiki.multimedia.cx/index.php?title=PCM
http://neyric.com/2006/10/14/decoding-mu-law-audio-stream-to-pcm/