Seamless Audio Loop Impossible in Unity ?

Hi there,
I know there are a lot of topics covering this problem but I havent found any solution yet, I cant belive that making a clear car engine loop sound in unity is impossible.

Im using the sounds from the Unity car example, the 4 channel one. If I prelisten the sounds looping in the inspector it sound nice, but as soon as I use it on Play mode there is a “pop, pop, pop” sound each time the clip loops.

I have tried with all the audio import settings and its impossible to solve this problem…

Unity can’t play a loop? sounds bad.

Personally i can control the loop into the output stream of the soundcard except it takes a day or two to write the sound buffer queing engine. im going to need loops too soon so some info on this issue would be cool.

Some sounds don’t loop properly because they weren’t exported correctly from the recording program.

for a loop to work properly, you have to sometimes smooth the audio for the 2 samples on either side of the loop to prevent a click, in which case you have to read the sample number, and if it’s s.length or zero apply a smoothing algo which says : if next sample is more than .1 different from previous one next sample is .1 different and repeat until the samples are withing .1 of each other. dont know if that applies to unity, but it can be a fix which is much faster than reprocessing alot of loops which dont have matching start and end points.

I’m curious about this as well - I remember in past versions of Unity, if your audio was truly a seamless loop, you’d have to make sure you weren’t compressing the audio files, and Unity would (I think) loop them without a pop.

I’m making a game that uses looping heavily so once I get this figured out I’ll let you all know how I got it going.

Pat

Have you tried changing the load type in the import settings? Did you enable Preload Audio Data?

if there is a click, it’s perhaps ok to reduce the volume for 5 samples prior and after the loop point, if it happens that you finda programming scenario where you are having lots of dodgy loops… 44100/ 1 5th is 10000ths of a second or somthing

I haven’t given my work a reeeeaaall close listen, but having uncompressed audio that’s Preloaded definitely reduces the popping I was hearing before. I’ll take a closer listen sometime soon.

Remember not to use MP3 files as the source. Always use OGG when dealing with big files.

If the exported file loops correctly in your audio editing program, it will loop correctly inside Unity.

8 Likes

Audacity is your friend to fix samples that dont naturally loop: http://www.audacityteam.org/

Now, you have to understand basics to make samples continuous. Maybe I will make tutorial one day if someone is interested,

The most common mistake with loops sounding not right in an audio export while in the DAW environment it does, is that the loop is listened to pre-rendered in the DAW. VST/AU effects are dynamically determined there while when rendered/exported a delay or reverb isn’t calculated anymore on the source audio and therefore when looped can be full of artifacts. The delay or verb is simply cut off at the end.

As Miguel-Herroro noted, an audio loop (so rendered/exported from the DAW) that sounds good looped in any editor or DAW will sound good looped in unity as well.

@SoyUnBonus wow! I never thought that other formats than MP3 were better! But this solved my problem together with slight audacity editing. I have a couple of car engine sounds but half of them wouldnt loop correctly in Unity while in audacity they did fine. Thanks again!!

2 Likes

Converting to MP3 adds a tiny silence in the beginning and end of the file, so it won’t loop properly.Try using .wav or .ogg

10 Likes

I made an asset that simulates engine sounds, available in the Asset Store with engine sound packs: https://bit.ly/3aZ50Ag

yassssss finally, I had the same problem, I was trying to find the solution for 3 DAYS! AND THEN I saw that FRIKIN Audio Chorus FIlter was on. Damn I was so FRUSTRATED.

This is true! Thank you!

god this helped SO MUCH. THANKS!

i tried converting the files in a converter service online by the issue still persists :frowning:

I recommend you use a free tool such as Audacity or FFMPEG to convert your files. The first one is a great tool for simple audio edition, and it handles a bunch of formats, while the second is a notorious tool to convert audio/video formats, and much more!

2 Likes

I converted my audio file from mp3 to ogg and the looping is MUCH better. Thanks for help! :wink:

2 Likes