I am trying to create a simple metronome app for Android. It should play a short sound with very short intervals.
Max it should be 250 sound plays per minute.
Hence the shortest play duration is 60/250 = 0.24s.
I created a WAV file with beat sound. It’s duration: 0.15s.
The problem is that SoundEngine is playing sounds with latencies.
Thus when I press play should I hear the the beats are not accurate.
What I tried:
I tried to create TCastleTimer with CounteractDelays := true;
Also I tried it with CounteractDelays := false; the results are the same.
To play sounds I tried both:
Also I tried it without TCastleTimer:
On WindowUpdate I analyze Timeout and then fire play sound event.
Thus I think probably the TCastleTimer is accurate. But playing sound has some starting latency. Is there any way to improve it?
On Windows all variants/combinations of PlaySound/Sound, TCastleTimer/WindowUpdate are working fine. I hear the very accurate beats.
But I tried two Android phones: one is old and slow and another is new and fast and both phones plays sounds with not precise intervals.