- Home /
Why does sound on Android play at double speed and crackle?
I'm trying to get some sound working in a Unity project at the moment. The sound works perfectly fine in the Editor and in the iOS build.
When building for Android, however, the music makes a crackling/popping/static noise, and plays twice as fast. I've checked audio.pitch and it's set to 1 (and anyway, the pitch of the audio is not different, it's just as if half of the "audio frames" are missing). This applies to all my sounds.
I've tried:
Changing the sound from 2D to 3D and back
Changing compression to native
Changing compression amount
Changing load type
Forcing the sound to mono
Changing the Audio settings default speaker set up to mono
Using AudioSource.PlayClipAtPoint instead of an AudioSource component
Changing pan level when the sound was a 3D sound
Checking bypass effects
Playing on awake vs. starting from script
Testing on multiple devices
The sound files definitely play correctly outside of Unity (and in the Editor and iOS). Native Android sound files play correctly on the phone.
I can't think of what else could cause this, especially the playing twice as fast.
For now, I'm going to make the background music file into a native Android sound (though that breaks the abstraction barrier) and leave the smaller sound effects as they are (they don't seem to be as bad).
EDIT: My project is actually used as a library inside a larger native Android project. I normally test by exporting, then running my shell project. I just tested by exporting the Unity project straight to my phone and the sound worked fine. It looks like somehow my native Android code is interfering with the Unity music. Does anybody know how the Unity sound system works in terms of Android? Any thoughts on how my code could be interfering with it? I'm using a MediaPlayer to play some sounds in the native Android shell also.
Having this same issue, but only on one of the two apps I'm working on. I can't deter$$anonymous$$e which setting is different.
39thstreet -- Glad to hear it isn't just me. Let me know if you figure anything out. wilco64256 -- I'm importing from mp3 format, but doesn't Unity import it into it's own format anyway? It previews correctly in Unity so that seems to suggest that the import works fine.
Answer by 39thstreet · Aug 08, 2012 at 01:34 PM
Here's how I ended up fixing it: Project settings > Audio > Default Speaker Mode to Stereo. When it's in mono, it caused the issue I was having.
Thanks for the answer! I think I tried this already, but I'll test it out when I get the chance.
I just checked my Audio settings and the speaker mode is already set to Stereo. I wonder if there's some other setting that overrides this somehow?
Answer by Majkell · Apr 08, 2013 at 05:42 PM
I have been struggling with a same problem for few days and finally found the solution which worked for me, so I decided to share if someone stumbles upon this old thread.
You must not extend UnityPlayerActivity in Eclipse but plain Activity and sound issues are gone.
Answer by mirek.um · Nov 03, 2014 at 10:06 AM
Check audio sampling, if it's too high like 96KHz then sound can be distorted.