Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by tommyzat · Dec 05, 2016 at 06:09 PM · androidaudiosoundaudiosourcedelay

Fix sound delay

Hello!

I'm trying to play sounds on my android device, however they're always delayed by about half a second. Why is that?

Comment
Add comment
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

6 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by panoramabeats · Dec 06, 2016 at 12:28 AM

This is one setback of the Android OS in comparison to the iPhone/iOS all-inclusive atmosphere.

Because of the fact that there are simply so many different devices, the OS and the device are not always made to be one single cohesive item, if that makes any sense.

A Google search for 'Android audio kernel' will bring up most of the background information on the subject.

I'm not a fan of iPhone, but when it comes to audio latency in apps, it is actually superior.

This issue is mostly device-specific, but also has to do with processing. Are there background processes that can be eliminated.

How is your audio implemented in Unity? Are you using any middleware, etc.? An option you should select if possible is to pre-load the sample, instead of loading when encountered in the app.

Also, are you compressing your audio files to mp3 or an equivalent? Avoid using bulky WAV files, etc. if processing and latency are issues.

Hope this helps in some way.

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
avatar image
2

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

What you could do is Project Setting > Audio > DSP Buffer Size > set it to Best Latency (small buffer size). As of today with this settings, it make a glitched sound on Windows build while on macOS, Android, iOS is completely fine. You might want to have larger buffer size on Windows. (at the expense of more latency)


If "Best Latency" setting 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 · 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 derianmeyer · Aug 08, 2019 at 05:07 PM 0
Share

I was experiencing the same issue in a regular PC build (using .ogg files, not heavy .wav files). The DSP Buffer Size change fixed my problem. Great suggestion, thank you!

avatar image
0

Answer by lloydg · Jan 13, 2017 at 08:44 AM

It is unity doing fancy stuff with the audio, this is slow on Android.

I used this plugin to play sounds faster, its a bit limited in features: https://forum.unity3d.com/threads/android-sound-latency-fix.319943/

Note that the link is broken in the original post, however, on page 2 I have uploaded the files.

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
avatar image
0

Answer by LexH · Nov 23, 2018 at 10:20 AM

thanks a lot!!! Native Audio http://exceed7.com/native-audio/ 爬文許久 我還沒試過 但是 上面這個連結貌似可以 是目前我看到的最新解決方案

ps建議用英文搜尋 較冷僻的問題用中文搜尋不好找到

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
avatar image
0

Answer by Alexander-Fedoseev · Dec 12, 2018 at 12:07 PM

I'm using Master Audio plugin on Unity. With a new game I've noticed about 500 ms latency on Samsung S8 which was very confusing since on some old devices that i have there were not noticable latency. DSP Buffer Size to low latency helped a little. Ignore time scale switcher in Master Audio helped a little. But the latency didn't disapiear. So I've applied Native Audio plugin for Android and it works very well, but there is no such power and flexibility compare to Master Audio. And the only available sound quality for now is 16-bit PCM 44100Hz Stereo .wav which is not good for me. So what helped me to reduce the latency to about 100 ms i guess and made it acceptable for me is:

     private void PlaySoundAfterUpdate(string soundName)
         {
             StartCoroutine(PlaySoundAfterUpdateCoroutine(soundName));
         }
         
         private IEnumerator PlaySoundAfterUpdateCoroutine(string soundName)
         {
             yield return null;
             MasterAudio.PlaySoundAndForget(soundName);
         }

In most cases i ve tried to play sound in OnCollisionEnter2D or FixedUpdate. After I've started to wait until next Update the latency reduced dramaticly. Still not so low as in Native Audio, but acceptable for me. Hope it will help somebody.

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 5argon · Dec 12, 2018 at 12:11 PM 0
Share

Hello, alternatively for many Samsung devices + chinese phones you may try upgrading to 2019.1 alpha. It will instantly provide you less latency for non-native normal Unity audio playback. Please see my article here : https://gametorrahod.com/unitys-android-audio-latency-improvement-in-2019-1-0-ebcffc31a947

The reason your older devices got less latency is because of newer devices unfortunately not passing Unity's fast audio track criteria. These requirements were relaxed in 2019.1

  • 1
  • 2
  • ›

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

139 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Cracking at end of audio? 0 Answers

Need help: new sound isnt played correctly anymore 2 Answers

Second AudioClip won't play 0 Answers

How can i keep the same sound settings across different scenes?,How do i save the volume for sound into a different scene? 0 Answers

How to make audio overlap itself? 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