I’m having some trouble encoding certain configurations of multi-channel Apple Lossless files. I have no problems with 2, 4 and 6 channel configurations, however I’m running into trouble generating a 12-channel file.
Using the ExtAudioFile APIs, I’m able to create the audio file with a 12-channel AudioStreamBasicDescription and a 12-channel FileChannelLayout. When it comes to setting the 12-channel ClientDataFormat (done before setting the client layout, which, obviously also fails), I get the “fmt?" error code.
My AudioStreamBasicDescription for the ClientDataFormat is generated as follows:
AudioStreamBasicDescription asbd;
asbd.mSampleRate = m_sampleRate;
asbd.mFormatID = kAudioFormatLinearPCM;
asbd.mFormatFlags = kAudioFormatFlagIsFloat;
asbd.mBytesPerPacket = m_channels * 64 / 8;
asbd.mBytesPerFrame = asbd.mBytesPerPacket;
asbd.mFramesPerPacket = 1;
asbd.mBitsPerChannel = 64;
asbd.mChannelsPerFrame = m_channels;
asbd.mReserved = 0;
The sample rate is 176.4 kHz and m_channels is correctly set. This has worked properly for 2, 4 and 6 channel setups, so I don’t think it is at fault. I’ve also tried using 32-bit signed integers instead of 64-bit floats, but the result is the same.
I’m not sure what I’m missing. Is it possible the Apple Lossless codec doesn’t support 12-channel encodings?
I don't know for certain if the spec at MacOSForge is definitive, but according to http://alac.macosforge.org/trac/browser/trunk/ReadMe.txt
3. From one to eight channels are supported. Channel orders for the supported formats are described as:
Num Chan Order
1 mono
2 stereo (Left, Right)
3 MPEG 3.0 B (Center, Left, Right)
4 MPEG 4.0 B (Center, Left, Right, Center Surround)
5 MPEG 5.0 D (Center, Left, Right, Left Surround, Right Surround)
6 MPEG 5.1 D (Center, Left, Right, Left Surround, Right Surround, Low Frequency Effects)
7 Apple AAC 6.1 (Center, Left, Right, Left Surround, Right Surround, Center Surround, Low Frequency Effects)
8 MPEG 7.1 B (Center, Left Center, Right Center, Left, Right, Left Surround, Right Surround, Low Frequency Effects)