4

Is it possible to play sounds with sub-millisecond latency using Core Audio?

I've tried using AudioQueues with different sizes and numbers of buffers, and I've tried using AudioUnits, but I have been unable to get below 30 ms of latency.

I am using an oscilloscope to measure the time between when a pushbutton on an Arduino is pressed and when sound leaves the audio jack. The Arduino communication never contributes more than 1 ms of delay.

flutillie
  • 554
  • 1
  • 7
  • 19

1 Answers1

4

No. For sub-millisecond latency, not including DAC latency, the audio driver would need to pull a buffer size of 32 samples or less at a 44.1k sample rate, which output Audio Units don't seem to allow on current hardware. Audio Queues run on top of Audio Units and thus have an even higher latency.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • I am replacing code that was written using the SndManager system on OS 9, and this old OS 9 code is able to achieve better latency times than I can on a new Mac. Is there any way I can replicate this? – flutillie Jun 30 '12 at 14:17
  • @flutillie, No, there isn't. Now, you should be able to get well below 30ms depending on the hardware, but sub-millisecond latency isn't possible. – Brad Dec 09 '12 at 06:07
  • 1
    Hi Brad, I managed to solve my problem. I have gotten the latency down to sufficiently small levels by using a 32-byte buffer, and instead of stoppping/starting the audio units, sending 0s when I want silence. Thanks for your help. – flutillie Dec 13 '12 at 03:33