Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by meat5000 · Aug 30, 2013 at 09:30 PM · androidaudiodelayplaybacklatency

!RIDICULOUS! Audio Latency - Android

Ok, so making my Physics 'Puzzler' I've run into what seems like a common issue. I'm getting Beefy delays in my Audioclips, only on Android. Of course, in editor there is no issue.

I read something about pre-buffering but found no info on how. The AngryBots tutorial on Android has no delays and from what I see, nothing special to make it work. I only have one audio clip! 44.1k mp3 at 16-bit PCM! ....its 630ms long.

Other than 'Best Latency', is there anything I can do to reduce delays without writing a plugin or using FMOD? And does anyone have a resource on implementing SoundPool?

Getting a bit vexed. The size of my file is 4.12KB!!! I've reduced it to less than 300ms long soundclip. I still get 0.5 second delay??

EDIT: So far the best latency on my device is achieved at (256, 2) output buffer. Seriously low values. Still ~300ms delay but better than 500ms!

Comment
Add comment · Show 14
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Aug 30, 2013 at 09:40 PM 0
Share

Ok, I've moved the Audio Listener right next to the sound (it was 400 Units away) and the delay is exactly the same. So sound does not appear to travel.

avatar image Hyperion · Aug 31, 2013 at 01:44 AM 0
Share

Do you have Audacity? Because using WAV sure saves memory! And thus, you might want to try converting your mp3 to a wav format (I hope you're not using $$anonymous$$ac). If you don't know how to use Audacity, I can tell you the steps.

avatar image meat5000 ♦ · Aug 31, 2013 at 02:15 AM 0
Share

Yeah Ive got it installed, just installed Lame today :/

Yeah I'll give that a shot, although 4.12 $$anonymous$$B is pretty damn small :P Can't believe Android is choking for half a second on that!

:D

Where'd dudes comment go? I see what he's asking now! :D Decompress on Load isn't there for WAV files!

They seem to be a lot bigger than $$anonymous$$P3 too.

The wav equivalent of my $$anonymous$$P3 is 37$$anonymous$$

avatar image Jamora · Aug 31, 2013 at 02:53 AM 0
Share

Are you storing it in memory or strea$$anonymous$$g from disk?

avatar image meat5000 ♦ · Aug 31, 2013 at 02:58 AM 0
Share

Decompress on Load

4$$anonymous$$B.....

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by metaphysician · Sep 14, 2013 at 09:48 AM

for really short sounds i'd recommend WAV or some PCM variant. i'm fairly certain Unity/FMOD supports ADPCM which should get you 4:1 compressions and Audacity can export ADPCM formatted WAV files just fine.

also the latency fixes with Jelly Bean that the Android engineers showed at Google I/O only work on a few devices. that's the biggest issue. you don't really know if your app will be running on a quad core Snapdragon, or a dual core Rockchip ARM processor. this post has a bit more info as well as links for the Google presentation:

http://createdigitalmusic.com/2013/05/why-mobile-low-latency-is-hard-explained-by-google-galaxy-nexus-still-android-of-choice/

and the article mentions three devices that support the new low latency features: from the article: "So, which Android should you get (if any)? ...There are three devices that support the low latency profile, up from one device at Google I/O last year: 1. Galaxy Nexus (Samsung) 2. Nexus 4 (LG) 3. Nexus 10 (Samsung)"

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Sep 14, 2013 at 09:47 PM 0
Share

Ok, ill try these formats and see what happens.

Interestingly, running my quad core Xperia Z has audio lag in my own Unity game but not others. Also interesting to note is that a friends ancient Android 2.3 device has no lag at all.

Thanks for the information!

avatar image meat5000 ♦ · Sep 18, 2013 at 04:52 PM 0
Share

I've tried all the file types now. No difference on a any of them with respect to delay.

avatar image
2

Answer by ChristopherCreates · May 02, 2015 at 03:14 PM

I've just released an asset that can help! It provides access to the native Android audio system, which removes most of the latency generated by Unity.

http://u3d.as/content/christopher-creates/android-native-audio

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Jun 24, 2015 at 10:29 AM 0
Share

Excellent find. Nice price. Hope it works!

avatar image
0

Answer by 5argon · Apr 14, 2018 at 04:17 AM

If "Best Latency" setting (small buffer size) is still not enough for you going native is definitely the way to go. I just made Native Audio asset store plugins which can make a native call to both iOS and Android's fastest native way from one central interface. https://www.assetstore.unity3d.com/#!/content/107067


There are various ways of playing audio at native side, here's my choice :

  • On iOS it uses OpenAL. It is faster than AVAudioPlayer, AudioToolbox, and SystemSound.

  • On Android it uses AudioTrack, I confirmed it to be faster than SoundPool and no meaningful difference from C++ side OpneSL ES of NDK.

I have compiled all of my findings in here : http://exceed7.com/native-audio


PS. I have used FMOD for Unity before. The best settings that I could do. In addition to setting the best file format, requires editing FMOD Unity's source code to use very low number of buffer size. With that still the latency is just about equal to Unity's "Best Latency" (ant the sound cracks more too due to a low buffer size)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Playing mp3 files on Android 1 Answer

Android audio delayed on some android devices 1 Answer

Major Latency on Android when using Microphone 1 Answer

Microphone Input Latency Android 1 Answer

android audio delayed 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges