I've converted a file and get the wrong bit rate reported by afinfo. The input file is a 16bit 44.1 wav file, the output file is a 12 bit 26040hz caf file defined like this:
AudioStreamBasicDescription outputFormat;
outputFormat.mSampleRate = 26040;
outputFormat.mFormatID = kAudioFormatLinearPCM;
outputFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsAlignedHigh;
outputFormat.mBytesPerPacket = 2;
outputFormat.mFramesPerPacket = 1;
outputFormat.mBytesPerFrame = 2;
outputFormat.mChannelsPerFrame = 1;
outputFormat.mBitsPerChannel = 12;
UInt32 outputBitRate = (outputFormat.mSampleRate * outputFormat.mBitsPerChannel); // 312480
When using this bit rate in AudioConverterSetProperty with kAudioConverterEncodeBitRate, I get a 'prop' error. Setting the bit rate to 0 gives me this in afinfo, indicating that the output file is 16 bits.
infile:
File: /Users/fred/desktop/kick.wav
File type ID: WAVE
Data format: 1 ch, 44100 Hz, 'lpcm' (0x0000000C) 16-bit little-endian signed integer
no channel layout.
estimated duration: 0.196 sec
audio bytes: 17248
audio packets: 8624
bit rate: 705600 bits per second
packet size upper bound: 2
audio data file offset: 44
not optimized
outfile:
File: /Users/fred/desktop/spKick.caf
File type ID: caff
Data format: 1 ch, 26040 Hz, 'lpcm' (0x00000014) 12-bit little-endian signed integer, unpacked in 2 bytes high-aligned
no channel layout.
estimated duration: 0.196 sec
audio bytes: 10184
audio packets: 5092
audio 5092 valid frames + 0 priming + 0 remainder = 5092
bit rate: 416640 bits per second
packet size upper bound: 2
audio data file offset: 68
optimized
sound check:
approximate duration in seconds 0.196