No output from AVAudioMixerNode with 8 live input channels

I have a Mac app hosting a single, custom effect unit attached to an AVAudioEngine. For input, it works with either a looped audio file, or live input from the Mac's selected audio input device. In either case, the audio signals are routed to the Mac's built-in (stereo) output. Two-channel operation works fine for either input selection. When playing back a six-channel audio file, the engine's mainMixerNode correctly downmixes the six-channel data to the stereo output. When working with live input, I am testing an 8-channel input device. With 8 channel input, the mainMixerNode seems to lose the signals and I get nothing at the output.


By installing taps on the relevant nodes, I have confirmed that there is valid data in the signals at the output of the audio unit, which is connected to the mainMixerNode, and that I am getting zeros at the output of the mainMixerNode.


I have confirmed that the signal is also lost using 8 channels for both input and output (on the same audio device).


I have tried employing a separate AVAudioMixerNode to handle the 8-to-2-channel downmix, and it also produces zeros at its output.


I can't see any reason for the signals to be lost. Is there a known bug in the AVAudioMixerNode? Has anyone else observed this?

Accepted Reply

The AVAudioMixerNode must have an appropriate audio channel layout for the input data in order to successfully downmix 8 channels to 2.

The 8 channel input coming directly from an audio device, or from an AIFF file, uses

kAudioChannelLayoutTag_DiscreteInOrder
, which yields no output from the AVAudioMixerNode with 2 output channels.

I found that I could set the audio channel layout to whatever I wanted in the output format of my custom audio unit (connected to the input of the audio engine's mainMixerNode), and that certain channel layout tags would yield output signals (the distortion I mentioned in a previous post was due to a bug in my own code).

For 8-to-2 channel mixing, the following channel layout tags work:

  • kAudioChannelLayoutTag_AudioUnit_7_1
  • kAudioChannelLayoutTag_DTS_8_0_A
  • kAudioChannelLayoutTag_UseChannelBitmap
    • Bitmap: 0xFF
    • Bitmap: 0x8F7

The following tags do not:

  • kAudioChannelLayoutTag_Octagonal
  • kAudioChannelLayoutTag_UseChannelBitmap
    • Bitmap: 0x6F3
    • Bitmap: 0x5633

There are others that I have not tested.


In hindsight, it seems obvious that the mixer would need to have some clues about how the mixing should be performed, but I have not found even a passing comment regarding this in the documentation. The AVAudioMixerNode documentation merely indicates that it can mix any number of input channels to any number of output channels.

I remain unaware of how the mixing is actually performed, except for the clues inherant in some of the channel layout tags. It would be really nice to see some more comprehensive documentation on this.

Replies

In case it's relevant, I have everything operating at 48 kHz, so there is no sample rate conversion going on. The only thing changing in the formats between nodes is the number of channels. According to the docs, the AVAudioMixerNode "accepts any channel count and will correctly upmix or downmix to the output channel count."

Some additional info:

I tested this with an 8-channel audio file and I do get signal through, but it is distorted. It looks like blocks of samples are zeroed out at regular intervals.

The audio file has a channel layout that uses a bitmap to identify which channels are used (kAudioChannelLayoutTag_UseChannelBitmap).

The live input device has a channel layout that merely indicates discrete input channels (kAudioChannelLayoutTag_DiscreteInOrder).


Next, I tested it with an 8-channel audio file that has channel layout identical to the live input device. In that case, I got no output signals from the mixer node, just as for the live input.

At this point, it seems clear that the channel layout makes a significant difference, but it's not clear how to configure it, or at what point in the signal chain, in order to get a successful stereo mixdown from the mixer node.

The AVAudioMixerNode must have an appropriate audio channel layout for the input data in order to successfully downmix 8 channels to 2.

The 8 channel input coming directly from an audio device, or from an AIFF file, uses

kAudioChannelLayoutTag_DiscreteInOrder
, which yields no output from the AVAudioMixerNode with 2 output channels.

I found that I could set the audio channel layout to whatever I wanted in the output format of my custom audio unit (connected to the input of the audio engine's mainMixerNode), and that certain channel layout tags would yield output signals (the distortion I mentioned in a previous post was due to a bug in my own code).

For 8-to-2 channel mixing, the following channel layout tags work:

  • kAudioChannelLayoutTag_AudioUnit_7_1
  • kAudioChannelLayoutTag_DTS_8_0_A
  • kAudioChannelLayoutTag_UseChannelBitmap
    • Bitmap: 0xFF
    • Bitmap: 0x8F7

The following tags do not:

  • kAudioChannelLayoutTag_Octagonal
  • kAudioChannelLayoutTag_UseChannelBitmap
    • Bitmap: 0x6F3
    • Bitmap: 0x5633

There are others that I have not tested.


In hindsight, it seems obvious that the mixer would need to have some clues about how the mixing should be performed, but I have not found even a passing comment regarding this in the documentation. The AVAudioMixerNode documentation merely indicates that it can mix any number of input channels to any number of output channels.

I remain unaware of how the mixing is actually performed, except for the clues inherant in some of the channel layout tags. It would be really nice to see some more comprehensive documentation on this.