I’m trying to make use of ExtAudioFile's automatic channel layout mapping, but it doesn’t seem to work as I expected.
Here’s what I do:
I open a 6-Channel WAVE file with
ExtAudioFileOpenURL()set the client data format property (
kExtAudioFileProperty_ClientDataFormat) to 6-Channel PCM Audio Unit Canonicaljust out of curiosity read the file’s channel layout property (
kExtAudioFileProperty_FileChannelLayout) the resultingAudioChannelLayoutstruct has akAudioChannelLayoutTag_MPEG_5_1_Awhich is correct (the file is L-R-C-LFE-LS-RS)set the client channel layout property (
kExtAudioFileProperty_ClientChannelLayout) now, I use the slightly differentkAudioChannelLayoutTag_MPEG_5_1_C, which is L-C-R-LS-RS-LFE, which is what I want to use in my audio graphthen, the file is read with
ExtAudioFileRead()into anAudioBufferListthe buffer list is played back by the audio graph: scheduled sound player -> matrix mixer (to down-convert the 5.1 signal to stereo) -> default out
Everything works fine, except the channel mapping doesn’t. The matrix mixer still receives a L-R-C-LFE-LS-RS stream.
I checked the docs for kExtAudioFileProperty_ClientChannelLayout:
This property’s value specifies the channel layout of the buffers in an
AudioBufferListlist that you pass to theExtAudioFileReadandExtAudioFileWritefunctions. This layout may be different from the file’s channel layout, in which case the extended audio file object’s underlying audio converter performs remapping. This property must be set after settingthekExtAudioFileProperty_ClientDataFormatproperty, and the number of channels in the two layouts must match.
I feel like I did it right, but I must be missing something… Does anyone have an idea how to make this work?