Lagspike when playing a sound? (only at android)

Monkey Targets Forums/Android/Lagspike when playing a sound? (only at android)

Salmakis(Posted 2013) [#1]
Hey, i have some lag spike when i play a sound in my game on android,
i actually use .ogg files for the sounds.

all i do is stuff like this to prevent sounds from being on the same channel.
	Function Play(snd:Sound)
		If EnableSound = true Then
			LastUsedChannel += 1
			If LastUsedChannel > 7 Then
				LastUsedChannel = 0
			End If
			PlaySound(snd, LastUsedChannel)
		EndIf
	End Function

when i play 1 sound effect i have sometimes (like 50/50 chance) a little lag spike, wich is really annoying.

when i have my EnableSound on false then i have not any lag spikes, so it can only be the PlaySound call.

Should i use another file format instead of ogg?
or any other ideas what it can be?


Midimaster(Posted 2013) [#2]
How big is your sound? Filesize? Length?


Salmakis(Posted 2013) [#3]
hey, ty for your time, the file is:

4,71 KB (4.827 Bytes) big and around 115 milliseconds long

edit:i replaced the sound now, and still the same issue :(


i tried alot of suff:
other formats and sound effects,
use .play(sound) in OnRender or OnUpdate

i even wroted me something that can only 1 sound played at a timme (to avoid if i maybe spam alot sounds by mistake)

its all not helping, but a friend told me that he dont have this issue on his smartphone, so maybe its an issue related to my phone only :(

well i surrender on that topic for now.


Midimaster(Posted 2013) [#4]
The size is absolute ok and should not cause problems....

Add a print command...
PlaySound(snd, LastUsedChannel)
PRINT "START " + Millisecs()

...to see, whether the sound is accidentally started several times instead of once...


programmer(Posted 2013) [#5]
Try this:
http://www.thiagorosa.com.br/en/how-to/improve-soundpool-performance