[Explained] What Causes the Mechanical Sound Effect Delay in Android?

jaredmorgs

Moderator
Staff member
May 8, 2012
4,334
3
Problem

Mechanical effects in all Android tables seem to be running up to a quarter second behind the action on the table.

Additionally, when game soundtrack music loops, there is a noticeable playback gap in the music stream.

Background

(from http://digitalpinballfans.com/showthread.php/6182-Pack-19-Beta?p=108893&viewfull=1#post108893 )

TPA uses a custom made in-house audio mixer that mixes everything into a single channel, which is then sent as a stream to the java side (of the Android version) to be submitted in chunks to the OS.

Cause
(continued from http://digitalpinballfans.com/showthread.php/6182-Pack-19-Beta?p=108893&viewfull=1#post108893 )

The mixer appears to be a bit laggy: more so on some devices than others (the first-gen Kindle is particularly bad).

Workaround

There is no workaround to this issue, unless the mixer is completely rewritten.

Additional Info
All info provide by responses from (@Ryan Routon) in the following threads:
http://digitalpinballfans.com/showthread.php/6182-Pack-19-Beta?p=108944&viewfull=1#post108944 and http://digitalpinballfans.com/showthread.php/6182-Pack-19-Beta?p=108893&viewfull=1#post108893

Q: What about the flipper sounds: they aren't affected?

A: The flippers don't have this problem because these effects are played from a sound pool (using .ogg files directly). Unpack the apk (it's basically another name for a zip archive) and you'll see them towards the top of the tree.

Q: Why not provide all mechanical sounds through the sound pool?

A: Due to the game framework it would be impossible to provide all sounds in a sound pool. All sounds are included in a big byte chunk for each table. Flippers are universal so those are fine to sound pool.

Q: What have you tried to fix the issue?

Decrease the audio block size: every time I (@Ryan Routon) make the block size smaller to pass to the Stream it breaks some devices and you hear blips in between. Bugs me to no end but not sure what to do.

Q: Why not make the block size tunable by the user?

A: The block size is device dependent, and is queried automatically by the OS for the most optimal block size. Anything smaller than optimal and the audio stream just does not work, which would likely result in a force closes because the buffer is trying to read bytes that aren't there.

Q: So what is the underlying issue that is causing the headaches?

A: It is actually the streaming aspect that is causing the delay. Even google admits that the latency issues have been a long-standing issue on Android. They have been improving since ICS, but are still not really quite right.

 

mmmagnetic

New member
May 29, 2012
601
0
Thanks for the explanation, I thought it was just me going crazy when I tried TPA on my new Nexus 7.

Quite a big bummer, but hopefully there will be a solution sometime in the future. Let´s see what 4.4 will bring!
 

Members online

Members online

Top