Unity Tutorial: How to create a seamless audio loop without a clicking sound

Today I decided to add audio to my Tesla Simulator. The cars by Tesla Motors are powered by electricity so I couldn't find a classic engine sound I could download from somewhere on the Internet. So I had to look through YouTube videos to find someone who drove a Model S and at the same time didn't talk. That wasn't and easy task! But I found about 3 seconds of electric car engine sound, which is actually mostly sound from the air and the tires.

I imported this mp3 file into Unity and added it to the cars. But, to my horrors, the sound wasn't looping correctly and it made a clicking sound each time it looped. I made a Google search to find a solution and noticed that a lot of other people had the same problems in Unity with "Audio "click" at loop point" and "Clicking wav loops." But no-one had a good solution. 

After a few trial and errors I found a good and easy solution. What you need to do is to make your audio file "seamless", like those seamless textures. This is how it is done:
  1. Download Audacity, which is a free, open source, cross-platform software for recording and editing sounds.
  2. Open your sound file in Audacity.
  3. With the left-mouse pressed, mark the part of the audio file that will make up the entire loop. The end and the beginning audio-lines should end close to the "zero" line, which is the black line in Audacity.
  4. Copy it and paste it into a new file.
  5. Now we need to make it seamless. Mark a small part of the beginning of the audio (with the left-mouse pressed), go to Effects and pick Fade In. Then mark a small part of the end of the audio, go to Effects and pick Fade out.
  6. Go to File and pick Export Audio.
  7. Drag the exported audio into Unity and you will hopefully not hear a clicking sound each time the audio file loops!


Post a Comment