ExtAudioFile API crash when reading compressed file with different sample rate
ExtAudioFile API crash when reading compressed file with different sample rate
- Subject: ExtAudioFile API crash when reading compressed file with different sample rate
- From: Michael Tyson <email@hidden>
- Date: Sun, 28 Aug 2011 18:59:55 +0200
Hi!
Guys, my brain hurts. I'm having a some real trouble loading compressed audio files using the ExtAudioFile API, when the files in question have a sample rate different to the target rate.
I'm trying to load the files into memory as 16-bit LPCM at 44.1k. The code works like a charm with all files also at 44.1k, but at other rates, I'm seeing a crash in ExtAudioFileRead (specifically, in SRC_convert_table_i16_scalar_stereo, within AudioConverterFillComplexBuffer).
And here's a tiny sample project that demonstrates the problem, with 44.1k and 48k sample MP3 files: http://resources.atastypixel.com/AudioFileLoadTest.zip
In summary, I'm:
1. Opening the source file,
2. Obtaining kExtAudioFileProperty_FileDataFormat,
3. Setting the target audio description to match the number of channels (otherwise it's 16 bit LCPM at 44.1k),
4. Applying kExtAudioFileProperty_ClientDataFormat,
5. Grabbing kExtAudioFileProperty_FileLengthFrames,
6. Allocating a buffer to hold the loaded audio (fileLengthInFrames * targetAudioDescription.mBytesPerFrame)
7. Performing one ExtAudioFileRead (cue crash, burn and hair loss here)
At present I'm assuming that the kExtAudioFileProperty_FileLengthFrames gives the length in the client data format (the docs seem pretty vague), but even assuming that it's giving it at the original sample rate, the crash still occurs.
So - does anyone have any ideas where I'm going wrong? Am I just doing something stupid?
Many thanks in advance!
Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden