AIFC files : temporary "AudioFile API fix"
AIFC files : temporary "AudioFile API fix"
- Subject: AIFC files : temporary "AudioFile API fix"
- From: Benjamin Golinvaux <email@hidden>
- Date: Thu, 20 Feb 2003 14:16:40 +0100
hi
in case someone runs into the same problem as i did
(the AudioFile API incorrectly reporting 'big endian' in the stream
format
of AIFC little endian files), here is what I did to fix it. It's
somewhat
hacky and not really 100% efficient but I can live with this (but it
seems
to be functionally working in all cases)
1) go get the latest version of sndlib from
ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz
2) add these sndlib files to your project :
audio.c
headers.c
io.c
sndlib.h
sound.c
3) in your AudioFile opening routine, do this :
#include "sndlib.h"
bool IsLittleEndianSignedShortFile(const char* sndFilePath)
{
int format = mus_sound_data_format(sndFilePath);
// "bogus file" handling needs to be done
// somewhere else (for example where
// AudioFileOpen() is called)
if(format == MUS_ERROR)
return false; // i needed this for a breakpoint check
if(format == MUS_LSHORT)
return true;
else
return false;
}
in the audiofile opening code :
bool isLittleEndian = IsLittleEndianSignedShortFile(path);
// open the audio file
// retrieve the file stream desc in fSourceStreamDesc
bool isSignedInteger = (fSourceStreamDesc.mFormatFlags &
kAudioFormatFlagIsSignedInteger);
if(isLittleEndian)
{
if(isLittleEndian && isNotFloat && isSignedInteger)
fSourceStreamDesc.mFormatFlags &= ~kAudioFormatFlagIsBigEndian;
}
// and then you can create an AudioConverter, blah blah
......
The alternative was using ParseAIFFHeader in Sound.h but it seems to
only work with AIFF files,
not AIFC. Also, i could have checked the file type and/or extension but
i think this looks better
(also works with "untyped" and extension-less files i hope)
I have read the sndlib license which seems to allow static linking into
non-GPL apps, but i need to make sure it really does (otherwise
creating a dynamic lib is ok i guess)
hope this helps.
Benjamin Golinvaux
www.arboretum.com
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.