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.
- 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.