I am working on an iOS app where audio recording and playback should happen simultaneously but at different sampling rates.
Recording will be done through a connected USB Audio device, and playback is done through the inbuilt speaker. I am using AudioUnits for both recording and playback. AVAudioSession category is set to AVAudioSessionCategoryPlayAndRecord.
Problem is that, recording sample rate should be 96kHz whereas playback sample rate should be 8kHz and, both should run simultaneously.
Currently, whenever I use AVAudioSessionCategoryPlayAndRecord and setPreferredSampleRate to 96kHz, ultimately sampleRate property of AVAudioSession remains at 48kHz and I am loosing half of the samples while recording.
If I use AVAudioSessionCategoryRecord recording happens just fine. But I can't run the audio playback simultaneously with this category. I even tried AVAudioSessionCategoryMultiRoute with no luck, here sampleRate remains at 44.1kHz
So, my question is in iOS how to use different sample rates for recording and playback and, still run them simultaneously? Any advice or references are greatly appreciated.
Please let me know if any other details are required.