4

Regardless of the size of the buffers I provide the callback provided to AudioQueueNewInput occurs at roughly the same time interval.

For example:

If you have .05 second buffers and are recording at 44k the callback first called about at .09 seconds and then a second call occurs right after (.001 seconds). Then you wait again for ~.09 seconds. If your buffer size was .025. You would wait .09 seconds and then see 3 more buffers nearly instantly.

Changing the sample rate increases the latency.

Recording 16 bit 8k audio results in .5 seconds of latency between buffer floods.

So I suspect that there is an 8000 byte buffer that is being used behind the scenes. When it's filled my callback gets run with the given buffers until it is emptied.

I want to record 16k 16 bit audio with as little latency as possible. Given the above I always see about a quarter of a second of latency. Is there a way to decrease the latency? Is there an audio session property to set the internal buffer size? I've tried kAudioSessionProperty_PreferredHardwareIOBufferDuration but it does not seem to help.

thanks!

madmik3
  • 6,975
  • 3
  • 38
  • 60

1 Answers1

0

The Audio Queue API looks like it is built on top of the Audio Unit RemoteIO API. Small Audio Queue buffers are probably being used to fill a larger RemoteIO buffer behind the scenes. Perhaps even some rate resampling might be taking place (on the original 2G phone).

For lower latency, try using the RemoteIO Audio Unit API directly, and then requesting the audio session to provide your app a smaller lower latency buffer size.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • After working with the RemoteIO API for a bit i was able to get very low latency recording. This website helped. http://atastypixel.com/blog/using-remoteio-audio-unit/ – madmik3 Jan 10 '11 at 21:45