Search Unity

Seamless Audio Loop Impossible in Unity ?

Discussion in 'Audio & Video' started by JesusMartinPeregrina, Mar 21, 2016.

  1. JesusMartinPeregrina

    JesusMartinPeregrina

    Joined:
    Nov 2, 2013
    Posts:
    44
    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...
     
  2. drudiverse

    drudiverse

    Joined:
    May 16, 2013
    Posts:
    218
    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.
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Some sounds don't loop properly because they weren't exported correctly from the recording program.
     
  4. drudiverse

    drudiverse

    Joined:
    May 16, 2013
    Posts:
    218
    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.
     
  5. bayerly

    bayerly

    Joined:
    Apr 9, 2013
    Posts:
    25
    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
     
  6. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Have you tried changing the load type in the import settings? Did you enable Preload Audio Data?
     
  7. drudiverse

    drudiverse

    Joined:
    May 16, 2013
    Posts:
    218
    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
     
  8. bayerly

    bayerly

    Joined:
    Apr 9, 2013
    Posts:
    25
    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.
     
  9. SoyUnBonus

    SoyUnBonus

    Joined:
    Jan 19, 2015
    Posts:
    43
    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.
     
    maurib98, AguExposito, dick and 4 others like this.
  10. Cromfeli

    Cromfeli

    Joined:
    Oct 30, 2014
    Posts:
    202
    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,
     
  11. Tijs79

    Tijs79

    Joined:
    Feb 5, 2017
    Posts:
    16
    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.
     
    Last edited: Feb 14, 2017
  12. UltraGearGames

    UltraGearGames

    Joined:
    Jul 15, 2018
    Posts:
    3
    @Miguel-Herrero 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!!
     
    panderson9149 and Cromfeli like this.
  13. hcdjp

    hcdjp

    Joined:
    Oct 7, 2015
    Posts:
    224
    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
     
    BlairTRD, fmarahre, oleg_v and 6 others like this.
  14. slaczky

    slaczky

    Joined:
    Sep 26, 2015
    Posts:
    224
    I made an asset that simulates engine sounds, available in the Asset Store with engine sound packs: https://bit.ly/3aZ50Ag
     
    Last edited: Apr 25, 2023
  15. unity_lGs5NAP5uLt_sg

    unity_lGs5NAP5uLt_sg

    Joined:
    Jun 20, 2019
    Posts:
    3
    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.
     
  16. John_MLS

    John_MLS

    Joined:
    Sep 11, 2013
    Posts:
    24
    This is true! Thank you!
     
  17. Marzukh101

    Marzukh101

    Joined:
    Nov 2, 2020
    Posts:
    1
    god this helped SO MUCH. THANKS!
     
  18. baraaelhalabi

    baraaelhalabi

    Joined:
    Oct 19, 2022
    Posts:
    8
    i tried converting the files in a converter service online by the issue still persists :(
     
  19. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    416
    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!
     
    baraaelhalabi and SoyUnBonus like this.
  20. harvestergames

    harvestergames

    Joined:
    Dec 6, 2017
    Posts:
    1
    I converted my audio file from mp3 to ogg and the looping is MUCH better. Thanks for help! ;)
     
    baraaelhalabi and SoyUnBonus like this.
  21. baraaelhalabi

    baraaelhalabi

    Joined:
    Oct 19, 2022
    Posts:
    8
    I tried converting it again to OGG and it worked, Thank you so much for the help <3
     
  22. onetimepad

    onetimepad

    Joined:
    Dec 30, 2021
    Posts:
    7
    Wave file can have looping point (from which audio player will start looping). Unity handles it perfectly.
    For FL Studio users: FL have "Tune loop" function in Edison / Tools which is perfect and simple to do loops fast. You just export whole sample as wave file and you have start part and loop part, all in one file.