Change Mic output format in AVAudioEngine

I need to get the microphone output in a certain format that isn't equal to the hw format. To do this, I'm creating a AVAudioMixerNode which will have that format as it's output. However, I never receive any buffers when installing the tap on the mixer node. I thought the inputNode would flow upstream? Am I doing something wrong? Note that I'm not using AudioUnits or AudioQueues because I need to do some frequency filtering on the actual audio stream and thought this was the easiest way to do it.


Here's the code:


mixerNode = [[AVAudioMixerNode alloc]init];
//Attach node
[theEngine attachNode:mixerNode];
//Then connect inputNode (mic) to mixer node
[theEngine connect:theEngine.inputNode
                        to:mixerNode
                     format:[theEngine.inputNode outputFormatForBus:0]];
[theEngine startAndReturnError:&theError];

//Now set up the real audio format i want
    AudioStreamBasicDescription audioFormat;
    audioFormat.mSampleRate = 8000; 
    audioFormat.mChannelsPerFrame = numberOfChannels;
    audioFormat.mFormatID = kAudioFormatLinearPCM;
    audioFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
    audioFormat.mBitsPerChannel = 16;
    audioFormat.mBytesPerPacket = audioFormat.mBytesPerFrame = (audioFormat.mBitsPerChannel / 8) * audioFormat.mChannelsPerFrame;
    audioFormat.mFramesPerPacket = 1;
//Now install the tap on the mixer so we get the correct format
    [mixerNode installTapOnBus:0
                    bufferSize:4096
                        format:[[AVAudioFormat alloc]initWithStreamDescription:&audioFormat]
                         block:^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {
                             NSLog(@"got buff");
}];

did you find a way to do it ?

Can Apple weigh-in on this issue? I'm currently receiving samples as Float values and I also need signed 16-bit integer values. I don't want to convert these on the fly if I don't have to or if I can somehow get it for free at the source. Apple: How do we make this happen in code?

Change Mic output format in AVAudioEngine
 
 
Q