Hi,
Is Remote IO on iOS capable of sample rate conversion? Apple's documentation implies so, e.g.: "To avoid unnecessary sample rate conversion, be sure to use the audio hardware sample rate when defining your stream format." However, whenever I set a stream format with sample rate != [[AVAudioSession sharedInstance] sampleRate], the resulting audio is garbled.
My app code starts off by setting up the audio session:
AVAudioSession *theSession = [AVAudioSession sharedInstance];
[theSession setPreferredSampleRate:48000 error:nil];
[theSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
[theSession setActive:YES error:nil];
Later on, within my audio code (on top of Remote IO), I set up the stream format:
...
asbd.mSampleRate = 44100; // != 48000
status = AudioUnitSetProperty(au,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output, // the output side
1, // ... of the input element
&asbd, sizeof(asbd));
If I modify it to set asbd.mSampleRate = 48000, it starts functioning as intended.
So, is Remote IO capable of sample rate conversion and there's something broken in my code elsewhere, or do I *have* to use the audio session's sample rate?
Thanks.
P.S. Yes, I know there's a performance penalty for sample rate conversion, and I'm not doing it frivolously