Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Android audio latency

Author
Message
davei
6
Years of Service
User Offline
Joined: 30th Dec 2017
Location:
Posted: 7th Jan 2018 13:06
Hello.

There is about 300 ms latency when playing sounds on Android, which makes using AppGameKit impossible for rhythm games, and probably some other applications too.

Is there a way to solve this in Tier 1?

A possible solution would be using SoundPool class in Android SDK through JNI, which lowers the latency to 20-30 ms at worst. That's what some other music apps on the market use.

But apparently it's not possible to write Tier 1 extensions for Android yet.

Any help will be appreciated. I'm about to start building a set of music apps and I really want to use AGK.

Thanks!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 7th Jan 2018 19:51
i can't remember that it have so long delay but i had also problems in past making a piano app.
can you provide a example with your long latency ?
AGK (Steam) V2017.12.12 : Windows 10 Pro 64 Bit : AMD (17.12.1) Radeon R7 265 : Mac mini OS High Sierra (10.13)
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Jan 2018 23:15
Yes, I found the same problem. I found WAV suffers far more than Ogg, although I also found that very short Ogg sounds require silent padding at the end of the sample otherwise they don't play.
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 7th Jan 2018 23:18 Edited at: 7th Jan 2018 23:20
The latency doesnt seem that long on the android apps that I have made. They have to play sounds on screen touches and button presses and the delay seems hard to perceive. It may depend on your hardware.

Are you loading the sound file right before playing it??
What android hardware are you using?

Could you share some code??
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th Jan 2018 07:31 Edited at: 8th Jan 2018 07:41
Sorry... update on my last post: It's actually OggMusic that plays with far less latency, not ogg sounds. Ogg sounds are unpacked and used the same as wavs internally as far as I know so suffer with the same latency issues.

Using OggMusic is the only way I could get audio to play with low enough latency for a music "Instrument" type app, however other limitations in the OggMusic command set prevented me from taking it further (such as instances being queued and played once a previous sound finishes - no good for an instrument app, and without any instance control, there's no way to code around the problem).

Here's some example code used for testing. It produces a grid of 8 boxes that you can play as keys on a musical instrument. Provide your own samples and play with swapping Ogg for wavs and replacing the PlayMusicOGG commands with PlaySound etc.:



Login to post a reply

Server time is: 2024-04-25 02:37:58
Your offset time is: 2024-04-25 02:37:58