- Home /
Audio distortion and dropping out on Android
Had an issue with this for awhile and nearly tore my hair out, but finally got it resolved (mostly). I do have a few questions after the explanation though.
I have a bunch of prefabs with AudioSources playing short clips at specific intervals (strictly frame-based triggering using counters and Audio.PlayOneShot). Worked great in the Editor and PC Standalone. On Android the sounds would play distorted (not like digital clipping, was different), and often would drop out halfway through. The strange thing is that I have a different project using the same sounds, and never had any issue, even playing multiple ones at once. I tried everything I could think of from reading multiple threads about this, like Audio Settings tweaking, clips compressed/raw, convert to mono, etc...nothing seemed to work.
So...what was the magic fix?? I set
Application.targetFrameRate = 60;
At 30 it was causing the issues. Strange, I thought increasing the frame rate would make a problem like this WORSE, not better! But maybe the increased frame rate somehow allows the audio to happen...better? Can anyone shed some light on that?
Also, is it helpful in this case to tweak the DSPBuffer Size, and if so, what should it be set at? For this project I need accurate timing, which would be lowest latency, I suppose...but if it comes at the expense of distorted sounds, then...well, you get the picture (hair being torn out of an already-thinning head)...
Anyway, hope that helps someone down the road...it almost made me abandon the project, except I knew it had worked in the earlier project, so I kept at it...and so far, so good at the higher frame rate. But if anyone has words of wisdom about this, I would love to hear them. Thanks!
Answer by seejayjames · Jun 06, 2014 at 03:29 AM
Update: On that same device, later, the 60 FPS started crackling too. Not nearly as bad, I don't think it will be usable. Will try on other devices (Android phone and iOS) and see if anything changes...
Answer by gvexplorer · Jul 31, 2014 at 05:33 PM
Hi, I do not have an answer. However I do have a similar problem. As an interesting experiment to see if this is in fact the same issue, on different android devices (i.e. this is not a silly hardware issue) I noticed when using headphones, the sound is perfect. When listening on speaker, on multiple different handsets, the sound crackles the way you describe. If you do not mind, and I know it sounds crazy, could you please try and listen on earphones and see if the same is true for you? I wonder whether when you thought frame settings fixed the issue, you perhaps were listening over earphones, and yes I really would love to know how to fix this issue. .... BTW I have resolved my issue, it was down to how I recorded the sound in the first place in audacity. Using 1 input channel rather than recording in 2 input channel mode meant the sound works fine on android as well now. Hope this helps you...