6s microphone core audio - still can't fix rattling light popping sound

Despite my best efforts I am still getting a light rattling distortion sound on my core audio app when recording with the 6s in speaker mode

I've read all the other posts on 6s 48000 mic issues and believe i am doing everything correctly - I'm setting up my graph and client formats correctly as far as I can tell , and not expecting a certain number of frames any where in my code


My app needs to use core audio run at 44,100 because it mixes the live mic with sampled content that is 44100.0

It also needs to have the AVAudioSessionCategoryOptionDefaultToSpeaker flag set because it monitors audio out of the speakers when the mic is off


Here is a scaled down example - I'm connection the remoteIO input -> mixer -> remoteIO in typical fashion and setting the stream formats here is what my initialized running augraph looks like in the console


AudioUnitGraph 0x599000:
  Member Nodes:  
  node 2: 'auou' 'rioc' 'appl', instance 0x136fbafc0 O I
  node 3: 'aumx' 'mcmx' 'appl', instance 0x13803ce00 O I
  Connections:
  node   2 bus   1 => node   3 bus   0  [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
  node   3 bus   0 => node   2 bus   0  [ 2 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
  CurrentState:
  mLastUpdateError=0, eventsToProcess=F, isInitialized=T, isRunning=T (1)


I record my file inside a render callback using ExtAudioFileWriteAsync attached to the mixer I set my client format propertly to 44100.0

OSStatus  nCallback(void *inRefCon,
                         AudioUnitRenderActionFlags *ioActionFlags,
                         const AudioTimeStamp *inTimeStamp,
                         UInt32 inbusNumber,
                         UInt32 inNumberFrames,
                         AudioBufferList *ioData) {

    Engine *This = (__bridge Engine*)inRefCon;


    if(!(*ioActionFlags & kAudioUnitRenderAction_PreRender)) {

          ExtAudioFileWriteAsync(This->_EAFR, inNumberFrames, ioData);

    return noErr;
}



I've tried attatching the callback to the mixer output as well as the output remote io and the client format set correctling and the resulting file still contains the light crackling sound on the 6s


Here is the crazy part - which is possibly a red herring - If i remove the AVAudioSessionCategoryOptionDefaultToSpeaker flag my resulting recordings are fine. I'm out of ideas to try. Thanks!

Update - it appears that setting the stream format to 44.1 STEREO instead of 44.1 MONO before connecting it to the mixer also removes the light popping on the 6s - but then I can only have a left channel running through my graph - if i insert a render callback and manually mix the sounds the popping comes back!

Hi edfilo,


Could you please file a bug on this at bugreporter.apple.com?


Also, could you please note whether you only see the issue when you are forcing the sample rate to 44100? Does it also occur when you set it to 48000? Does it occur on other devices you have tested?


Thanks!

I wasn't able to narrow things down sufficient for a bug report, but using my iPhone 6s speaker in conjuction with recording from the microphone at any rate other than 48000 sps seemed cause some weird distortions in the signal path, not sure if it sounded like it might be the resampler anti-alias filter, a dropped single sample, or something else. So I ended up setting the input rate to 48000 on all the latest iPhones and iPads, and using the extra CPU power on those devices to do any needed rate resampling in my own code.

Thanks. How did you go about the resampling back down to 44100 - where in the signal chain - would this method be possible while mixing with AUFilePlayer units that are playing material recorded at 44100.0 ?

Accepted Answer

Thanks for the extra detail hotpaw2.


Please take a look at this forum post by one of the Developer Technical Support team folks:

https://forums.developer.apple.com/message/72961


Let us know if that doesn't help clarify matters for you.

Thanks - but I don't see anything in any of those articles about how to perform an actual conversion down to 44100.0 - hotpaw2 is setting the input client formt to 48000 as a workaround and rendering audio from the mic and downsampling it manually - where does the conversion from 48000 down to 44100 happen? - is he using a specific kind of sample converter in the callback? or an audiounit to do the conversion?

I didn't need to resample as part of the real-time audio signal chain. But later, to dump a large buffer to a WAV file that could be played back at 44.1ksps.


You might be able to do the opposite: resample your 44.1k content to 48k for mixing into a live 48ksps signal chain.

6s microphone core audio - still can't fix rattling light popping sound
 
 
Q