MacOS can't get buffer size any lower than 1024 in Unity

When lowering the buffer size of the core api system below 1024 to reduce latency (i.e. 128 x 2) I get the following warning and no audio plays:

Insufficient buffer size detected, requested 8192 bytes, buffer size is 2048 (or some other number depending on buffer size) bytes

What’s more, even Unity’s own audio engine can’t go below 1024 for me, I get this message in the project settings:

So this would seem to be a limitation of macOS, except that plenty of DAWs have no problem going down to 64 sample buffers. Any ideas about what’s going on here?

Hi,

This is a limitation of the MacOS/CoreAudio, which as you’ve noticed Unity is also subject to. If you set FMOD’s logging level to “Log”, and run a build Unity app in development mode from XCode, FMOD will log the maximum hardware read size in OutputCoreAudio::init. FMOD does not configure the audio hardware, so you won’t be able to push the OS’ buffer size any lower. By default, this should be 512 samples - if you want to safely lower FMOD’s default buffer size to match, you should be able to set FMOD’s buffer size to 512, and the buffer count to 2 (i.e. a double buffer of 512 samples).

It’s worth noting that it may be possible to lower FMOD’s buffer size even further, but:

  • The default update period of the Studio system’s asynchronous update thread is 20ms, meaning that lowering the buffer size and thereby increase the frequency of the audio mix will not actually affect the frequency at which Studio API commands, modulation/automation, etc. are enqueued, executed, and become audible
  • The buffer that MacOS expects from FMOD is subject to MacOS’ power saving mode - if power saving is enabled by the OS (which FMOD has no control over), it will increase the expected buffer size, which will break FMOD’s audio output. In this case, FMOD will log an “Insufficient Buffer Size” error in OutputRingBuffer::read

Ah gotcha, that makes sense! I’m aiming to just use the core api so I don’t think I should run into the 20ms update period.

Do you know if there’s a way to read the requested buffer size from the ring buffer? My thinking is that, if it’s possible, I could make a system that automatically sets the buffer size to the lowest possible for the user’s system before initializing the system.

If not would, would the closest thing be to just reinitialize the system with a larger buffer size if I get the “insufficient buffer size” error?

Thanks so much!