Fmod studio 手机上延迟的(latency)一些处理方案
The FMOD software mixer mixes to a ringbuffer. The size of this ringbuffer is determined here. It mixes a block of sound da
fmod 使用软件混合时,计算延迟公式:
FMOD_RESULT result; unsigned int blocksize; int numblocks; float ms; result = system->getDSPBufferSize(&blocksize, &numblocks); result = system->getSoftwareFormat(&frequency, 0, 0); ms = (float)blocksize * 1000.0f / (float)frequency; printf("Mixer blocksize = %.02f ms\n", ms); printf("Mixer Total buffersize = %.02f ms\n", ms * numblocks); printf("Mixer Average Latency = %.02f ms\n", ms * ((float)numblocks - 1.5f));
故使用:System::setDSPBufferSize和
System::setSoftwareFormat
可以提高响应的速度(减少延迟).不过,调整这两个接口的参数,亦有可能会引起声音的失真,如声音抖动的现象。在android 系统下面,尤其明显。如果android api在17以上,可以通过AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE以及 AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER接口,取得手机原始的处理的buffersize以及samplerate,以降低手机的延迟。