- Home /
Unity keeps altering my audio asset on import...?
When I import my sound loop (of the sound a ball makes when it rolls on a hard surface) into Unity, Unity adds about 1/5th of a second of silence at the beginning of the sound and maybe 1/10th of a second of silence at the end. That in itself seems totally random to me.
In my audio editor, there is no such silence visible (or audible) in the waveform. It is a perfect loop. However, in the waveform shown in the Unity inspector, you can see the short silence at the beginning and shorter silence at the end. And of course, you can hear the silence when it plays. I thought maybe Unity was using some kind of cached earlier and messed up version of the sound file and wasn't reimporting properly, but even when I import it as different file names it doesn't change matters at all.
Has anyone ever had this little issue before?
I've "fixed" it by attaching a script that basically says "if the time of the sound is less than 0.1 second, go straight to 0.1 second, and if it's higher than the duration minus 0.1 second, go to 0.1 second". Works great, but that's really just hiding the symptoms, not curing the problem.
Is there some sort of file format that Unity doesn't like for sound loops? The loop is in MP3 format, and is a pretty crappy bit rate (Think in the neigborhood of ~50kbps) because the source unfortunately had to be recorded that way, but I don't see how that would have anything to do with it.
My script fixes the problem, but I'd like a real fix if one exists just because it bugs me to have to remember to apply a script to every single loop. :(
Answer by marklin · Dec 15, 2016 at 03:36 PM
I think the correct solution is to use WAV audio files (instead of MP3 in my case). Using WAV, Unity won't add that annoying silence. If you're concerned about WAV file size (as these files are not compressed like MP3), don't worry because Unity will compress them. For example, a small sound as WAV is 383KB in size but Unity compresses it down to just 18.2KB.
Answer by NotIWhoLive · Jun 13, 2011 at 03:58 PM
I'm having this problem too. Did you ever figure out the answer?
Answer by GurtejKanwar · Jul 27, 2012 at 05:03 PM
Do you have Gapless Looping enabled? Gapless looping fills in silence to make the sound fit to the nearest "audio frame" I believe.
See this forum post for something similar to your issue -- http://forum.unity3d.com/threads/66090-Gapless-MP3-playback.
Your answer
![](https://koobas.hobune.stream/wayback/20220613101800im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why Doesn't My Music Loop? 5 Answers
Is there a way to create a random Audiosource loop? 2 Answers
How do I import audio and what type of audio do i need (mp3, etc.) 1 Answer
Can't get a sound to loop 2 Answers
VERY irritating.... I need help with playing and switching sounds in Javascript code... 1 Answer