0
0

I’m writing a custom DSP for an iPhone application, and for it I need a fixed, known number of samples being passed every read update.

Calling getDSPBufferSize after system::init tells me there are 4 buffers at a length of 1156 each. However, inside of my DSP I’m getting buffers of size 557 and 558.

I tried changing the buffer size manually with a call to setDSPBufferSize (before the init call), but despite not returning an error, this size is ignored. I assume that this is for hardware optimization purposes but thought it should be mentioned.

I would like to fix the number of samples returned to me at 512 or 1024, but at the very least I need to know what I can expect to be returned to me regularly. What’s up with the difference between getDSPBufferSize and what I’m actually getting?

  • You must to post comments
0
0

On iPhone you are correct, we have an optimization in place which makes reports from that function a little inaccurate, setting the DSP buffer size on iPhone has no effect and numbuffers is irrelevant.

The number you are getting (1156) is actually the maximum number of samples that the hardware could ever request of us, hence potentially the largest number of samples you will see in a DSP read callback.

In practice though it generally results from the output sample rate chosen and the fact that the hardware polls at around 23ms. Using those details, if the output sample rate is 22050 it will request an even 512 samples each time, and if it is 44100 it will request an even 1024 samples. Our default is 24000 which results in 557/558 samples (it switches back and forth), you can override the sample rate of FMOD by using System::setSoftwareFormat.

We can’t force the buffer size like we can on the Mac (the API is missing from iPhone), and we don’t want to buffer sound data to even it out if we don’t have to as this would introduce more latency. Unfortunately I cannot guarantee that what I mentioned above about polling rates and sample rates won’t change in the future either (although it’s unlikely).

All I can suggest is perhaps you buffer up data in your custom DSP if that is applicable to what you are trying to achieve, or set the sample rate to either 22050 or 44100 and assert if the rate is ever not 512 or 1024 respectively.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.