I'm just getting started with CoreAudio. Just trying to create an audio file, but getting a kAudioFileUnsupportedDataFormatError with the following.
Can any give me an idea why? It all looks okay to me, but I must be doing something wrong.
// Prepare the format
AudioStreamBasicDescription asbd;
memset(&asbd, 0, sizeof(asbd));
asbd.mSampleRate = SAMPLE_RATE; // 44100
asbd.mFormatID = kAudioFormatLinearPCM;
asbd.mFormatFlags = kAudioFormatFlagIsBigEndian;
asbd.mBitsPerChannel = 16;
asbd.mChannelsPerFrame = 1;
asbd.mFramesPerPacket = 1;
asbd.mBytesPerFrame = 2;
asbd.mBytesPerPacket = 2;
// Set up the file
AudioFileID audioFile;
OSStatus audioErr = noErr;
audioErr = AudioFileCreateWithURL((CFURLRef)fileURL,
kAudioFileAIFFType,
&asbd,
kAudioFileFlags_EraseFile,
&audioFile);
The "Core Audio Data Types Reference" contains the reference material for AudioStreamBasicDescription. But it's pretty dense and difficult to understand.
"Audio Unit Hosting Guide for iOS" has a section called "Working with the AudioStreamBasicDescription structure" that's a bit more helpful.
d.