Core Audio ExtAudioFile using Client Channel Layout

334 Views Asked by At

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 Canonical

  • just out of curiosity read the file’s channel layout property (kExtAudioFileProperty_FileChannelLayout) the resulting AudioChannelLayout struct has a kAudioChannelLayoutTag_MPEG_5_1_A which is correct (the file is L-R-C-LFE-LS-RS)

  • set the client channel layout property (kExtAudioFileProperty_ClientChannelLayout) now, I use the slightly different kAudioChannelLayoutTag_MPEG_5_1_C, which is L-C-R-LS-RS-LFE, which is what I want to use in my audio graph

  • then, the file is read with ExtAudioFileRead() into an AudioBufferList

  • the 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 AudioBufferList list that you pass to the ExtAudioFileRead and ExtAudioFileWrite functions. 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 setting thekExtAudioFileProperty_ClientDataFormat property, 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?

0

There are 0 best solutions below