Reputation: 11640
I was trying to set audio input to mono and output to stereo using two AudioStreamBasicDescription
s for one RemoteIO AudioUnit, which is the only AudioUnit there.
Then I registered two separate callbacks for input (kAudioOutputUnitProperty_SetInputCallback
) and output (kAudioUnitProperty_SetRenderCallback
), and expect that in my output callback, with AudioBufferList *ioData
, ioData->mNumberBuffers
should be 2.
But, to my surprise, it is still 1.
Is it that RemoteIO does not support having different channel numbers for input and output?
Upvotes: 0
Views: 781
Reputation: 11640
I seemed to have figured it out:
I was using signed-integer sample format, and with that format,
the input argument AudioBufferList *ioData
of the RenderCallback has only one AudioBuffer in it with interleaved audio samples (two output channel buffers concatenated into one), i.e., the AudioBufferList::mNumberBuffers
is one. Its only AudioBuffer
member in turn has an attribute mNumberChannels
which corresponds to the true channel count. In my case, that field is two.
An additional finding to support the above: Signed-integer format cannot be interleaved (tested with Xcode4.6 on OSX Mountain Lion), i.e., the property kAudioFormatFlagIsNonInterleaved
cannot be combined with kAudioFormatFlagIsSignedInteger
when setting the format flag of the ASBD.
If using float plus non-interleaved sample format, the AudioBufferList *ioData
of the RenderCallback has two AudioBuffer
s in the buffer list, each has the mNumberChannels
field as one.
Upvotes: 1