We develop iphone app that perform musical analysis on recorded audio from the iphone. Our app implementation make use of the audio queue service to receive raw audio buffers from the audio queue callback. In the first version of our app we had the problem of too much clipping on the recording which degrade the accuracy of our analysis. We also suspected that the noise canceling algorithm in iphone 5 produce distorted sound, which is not much noticeable by human ear but distorted enough to affect our sensitive algorithm. We found that the solution to our problem is to set the audio session mode to kaudiosessionmode_measurement. This session mode is supposed to give maximum freedom for us to control the microphone input, which include turning off the automatic gain control and probably noise canceling as well. The solution works very well except that it introduce a strange waveform pattern in the beginning of all recordings in iphone 5. It is very hard to explain the waveform we get, so i made two recordings at freesound so that you can see it visually. The first recording is made in an almost quite environment, and you can see the weird spike in the beginning of the recording. The second recording (this recording) is made with constant background noise, and you can see that the actual sound wave is offset from the strange curve and gradually increase to its original volume. This waveform only happens on iphone 5 devices that we tested, and there is no problem at all for iphone 4s and older generations. We have tried various settings and the glitch is still unavoidable as long as we set the audio session mode to kaudiosessionmode_measurement. We also find similar glitch in one of our iphone 5 devices, in which the glitch happens even if we try to set just the input gain level without changing the session mode. We are not sure if this is a hardware-related bug in iphone 5, or if it is fixable software glitch in the future version of ios. For the moment we are looking for workaround that can avoid this glitch while automatic gain control and noise canceling are disabled.
Author: Soareschen