2

I work on an audio Importer in JAVA (used in a drum sequencer) and I have the following problem with importing AIFF files:

I have 2 AIFF files of the same type (24bit, 44100kHz, mono), one is created on a Mac, the other is created with wavelab on a windows computer. Both files are uncompressed PCM, both are FORM == AIFF.

The AIFF from the Mac is BigEndian (as it should be), the AIFF from Wavelab (windows) is LittleEndian.

Both files can be played back properly in Wavelab (Windows) as well as in Quicktime (Windows). How can these tools detect the endianness of these files? In any way it must be possible, otherwise at least one of the files would sound just like noise (that's what happen in my application).

Is there some hidden information within the file header or any other way to determine the endianness of the AIFF file? Any suggestions?

Thanks a lot

gal
  • 441
  • 1
  • 4
  • 13

1 Answers1

3

A quick googling says, AIFF files are big endian.

However according to Wikipedia there is another format called AIFF-C that compresses data. Apple uses little endian these days and created a fake compression method named sowt that essentially means "no compression but little endian". You might have to check for that.

Apart from that, plain AIFF provides no way to check for endianness. A standard AIFF that is encoded in little endian seems to violate the specification.

musiKk
  • 14,751
  • 4
  • 55
  • 82
  • Yes, AIFF are big endian, I know. But wavelab creates 24bit aiff in little endian, that's a fact. This happens only to 24bit aiffs.. Every other bitrate is created properly as big endian with wavelab. I know, that may sound strange. But the file is, in fact, little endian – gal Sep 09 '11 at 09:00
  • Yes, I agree. Either the file violates the specs, or I'm doing something wrong while reading the header (I read it exactly the same way as for the 16bit aiffs, and there everything works as it should). I read about the fake compression 'sowt', but the file is not of that type. The header is of form type AIFF, not AIFC. Just wondering, how both files could be played back properly in quicktime – gal Sep 09 '11 at 10:00
  • Thanks for the link to the AIFF specs, great resource, very detailled – gal Sep 09 '11 at 10:46
  • I found something that could cause the problem. I cannot prove it for sure right now, but it seems, that I do not read the offset in the SSND chunk correctly. I'll check that tonight. – gal Sep 09 '11 at 11:10
  • It is the offset! Till now, I used a static offset of 8 bytes, which I skipped before reading the data. The 24bit aiff from wavelab seems to have a different offset. So the file is big endian, you were right. Just skipped bytes instead of 8 bytes and it works fine – gal Sep 09 '11 at 23:11
  • @gal: Great that you figured it out. :) – musiKk Sep 10 '11 at 12:35
  • 1
    In some code which I wrote years ago, I have a comment that says "According to David Ackerman, the compression type can change the endianness of the document." This is followed by code which checks for the 'sowt' compression type and changes the endianness to little. Dave Ackerman is a digital audio guru at Harvard who gave me information when I was writing that code, so that lends support to the statement about sowt in the answer above. –  Dec 07 '12 at 23:55
  • The muratnkoner site on WebArchive: https://web.archive.org/web/20181217154648/https://www.muratnkonar.com/aiff/index.html – MiB Aug 26 '23 at 11:45