Should be able to automatically (using channel maps) change the channel count of audio coming or going to a file.
Did this at one point, a long time ago. It looked roughly like this:
// If there's only single-channel input, set up a channel map to record to both channels
if (self.numChannels == 1) {
// Get the underlying AudioConverterRef
UInt32 size = sizeof(AudioConverterRef);
AudioConverterRef conv = NULL;
XThrowIfError( ExtAudioFileGetProperty(outputFileRef, kExtAudioFileProperty_AudioConverter, &size, &conv), "Could not get underlying converter for ExtAudioFile");
if (conv)
{
// This should be as large as the number of output channels,
// each element specifies which input channel's data is routed to that output channel
SInt32 channelMap[] = { 0, 0 };
XThrowIfError( AudioConverterSetProperty(conv, kAudioConverterChannelMap, 2*sizeof(SInt32), channelMap), "Could not set up mono->stereo channel map");
}
}
Should be able to automatically (using channel maps) change the channel count of audio coming or going to a file.
Did this at one point, a long time ago. It looked roughly like this: