0
0

I hanve encountered a problem when i currently working on a project with Fmodex-ios(Stable 4.44.30) to playback piano notes.
But i found that there is a noticeable latency after play a sound, about 100-200ms.

The latency happened in sound playback but not the touch event.
To verify it, i modified the examples project "playsound".
I simply add another playback(same .wav file) using AVAudioPlayer in the same touch event,
so i could clearly hear two sounds, and the sound which AVAudioPlayer played always came out first.
This test worked on The New IPAD.

I found another thread may described the same problem years ago but there is no solution yet.
http://www.gamedev.net/topic/589845-fmo … d-latency/

Is there any one came the same problem?

  • You must to post comments
0
0

Have you tried System::setDSPBufferSize?

The default is a buffer size of 1024, with 4 buffers. This is a quite generous result you should be able to get much lower on iOS.

The latency calculation for seconds is:
(buffer size * num buffers) / output rate

so…

(512 * 2) / 24000 = 0.043s = 43ms

Just test to make sure it doesn’t stutter with the reduced buffering.

  • You must to post comments
0
0

[quote="mathew":tkrd73rd]Have you tried System::setDSPBufferSize?

The default is a buffer size of 1024, with 4 buffers. This is a quite generous result you should be able to get much lower on iOS.

The latency calculation for seconds is:
(buffer size * num buffers) / output rate

so…

(512 * 2) / 24000 = 0.043s = 43ms

Just test to make sure it doesn’t stutter with the reduced buffering.[/quote:tkrd73rd]

Thank you for your reply.It solved.
By the way, should i set the same parameter on android?
I hanven’t start android version yet but I think this will also happened on android.
Does the output rate:24000 depend on OS or hard devices?

PS: But be careful that System::setDSPBufferSize should be called before System::init.

  • You must to post comments
0
0

You can set the output rate however you like vis System::setSoftwareFormat, however by default iOS and Android are 24KHz, everything else is 48KHz.

I’d recommend you test the buffer sizes carefully on Android, that platform has significant latency issues inherent in the OS and isn’t as forgiving as iOS with maintaining a small buffer.

  • You must to post comments
0
0

[quote="mathew":1tpj4azc]You can set the output rate however you like vis System::setSoftwareFormat, however by default iOS and Android are 24KHz, everything else is 48KHz.

I’d recommend you test the buffer sizes carefully on Android, that platform has significant latency issues inherent in the OS and isn’t as forgiving as iOS with maintaining a small buffer.[/quote:1tpj4azc]

Yes, i have tried android.
With the buffer size of 512, 2 buffers, or lower parameter, it came to stutter and became unacceptable.
I adjusted the parameter and found the 512,4 is the acceptable number about noise problem but i wish it lower such as latency in 512,2.

On IOS, even 128,2 can give a nice feel.

Some similar piano app on android seems to be nice performance. I have tried on java by using SoundPool or AudioTrack last year and it haven’t come out a big problem.
Is there any parameter I can adjust in fmod, or I can only write my own sound engine for android using AudioTrack.

Does System::setSoftwareFormat can do any effect? I tried to adjust it but it made worse.

  • You must to post comments
0
0

For Android we have two output modes, OpenSL and AudioTrack, I’d recommend using AudioTrack for the lowest latency.
You can choose this via System::setOutput(FMOD_OUTPUTTYPE_AUDIOTRACK), I’d recommend trying System::setDSPBufferSize(256, 2) with this mode.

That will give you the lowest possible latency on most Android devices without stuttering, unfortunately there isn’t any way to improve this due to latency inside the OS.

Some applications use SoundPool or AudioTrack with static samples, testing in the past has shown them to be slightly lower latency than FMOD in these cases. We use a single AudioTrack stream for output as we do our own mixing and sound manipulation which isn’t possible with static samples.

  • You must to post comments
0
0

I see. It seems android can only play static samples. It’s difficult to make android to play soft synthesize, which is shown to the fact that there is no synthesizer app on android.
I will consider this in my project. Currently, I have only considered static samples. But when a soft synthesizer is necessary(possibly for future version), it seems that I can only provide a limited edition for android, or I would have to expect higher performance hardware.

By the way, I tried System::setOutput(FMOD_OUTPUTTYPE_AUDIOTRACK) but the app seems to have no sound(on os ver 4.2).
If the solution above could make the latency to an acceptable level without stuttering, I may avoid to create my own audio functions for android, which would save a lot of programming effort.

  • You must to post comments
0
0

When using AudioTrack, there is a Java component too.
Make sure you create an instance of the FMODAudioDevice object and FMODAudioDevice::start to activate it.

You can see an example of this with our examples, if you still have trouble link with the logging version of FMOD and check out LogCat for details.

  • You must to post comments
0
0

OK, I’ll try Java Interface for android.
The explanation above is very useful, I think I can design a structure for my project now.
Thank you very much.

  • You must to post comments
Showing 8 results
Your Answer

Please first to submit.