Reputation: 1248
Im trying to record a little endian PCM file with AudioQueue. According to the docs I should clear the kAudioFormatFlagIsBigEndian bit in the AudioStreamBasicDescripton.mFormatFlags.
The docs says:
kAudioFormatFlagIsBigEndian. Set for big endian, clear for little endian.
My setup looks like
- (void)setupAudioFormat:(AudioStreamBasicDescription*)format
{
//format->mSampleRate = 8000.0;
format->mSampleRate = 44000.0;
format->mFormatID = kAudioFormatLinearPCM;
format->mFramesPerPacket = 1;
format->mChannelsPerFrame = 2;
format->mBytesPerFrame = format->mBytesPerPacket = format->mChannelsPerFrame * sizeof(SInt16);
format->mBitsPerChannel = 16;
format->mReserved = 0;
format->mFormatFlags = ~kAudioFormatFlagIsBigEndian | kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked | kAudioFormatFlagIsAlignedHigh;
}
The error I'm getting is
kAudioFileUnsupportedDataFormatError
Could anyone help me figure out whats wrong? Is it even possible to record little endian on an iOS device? One alternative to recording with little endian would be to convert the file later so any hints on that would also be much appriciated.
Upvotes: 0
Views: 1760
Reputation: 70733
Did you mean to request a sample rate of 44100.0 ?
The way to clear a flag is not to set every bit except that one as you have done (you probably set dozens of illegal bits in your example), but:
mFormatFlags &= ~(bitToClear);
Upvotes: 1