Search Unity

Is gapless audio looping possible in Unity

Discussion in 'Editor & General Support' started by flapyfox, Jan 31, 2013.

  1. flapyfox

    flapyfox

    Joined:
    Sep 9, 2008
    Posts:
    381
    I Know the option is there but it never works, its ether white noise ether a "tick" sound when the audio loop restarts.
    We are about to make a musical game but without that simple option its just impossible (it shouldn't even be an option, it should be done automatically).
     
  2. foxter888

    foxter888

    Joined:
    May 3, 2010
    Posts:
    530
    so far nope, you can't really mess with the audio itself, if you are trying to make a perfect loop get audacity which is a free sound application
     
  3. flapyfox

    flapyfox

    Joined:
    Sep 9, 2008
    Posts:
    381
    I already have a .wav perfect loop, its just it doesnt loop in Unity without a "tick'' or a white noise when it restarts, already tried all options.
     
  4. dbryson

    dbryson

    Joined:
    Nov 9, 2009
    Posts:
    269
    I haven't tried this, but I find it incredible that it doesn't work.
     
  5. fbgbdk4

    fbgbdk4

    Joined:
    Apr 10, 2012
    Posts:
    128
    I'm still not in the sound stage of my game, but if this is the case, I'll be worried.
     
  6. flapyfox

    flapyfox

    Joined:
    Sep 9, 2008
    Posts:
    381
    If you use a .wav file without "gapless looping", you will hear a white noise when the loop restarts.
    If you check "gapless looping" you will hear a small "tick noise" when the loop restarts.
    If that's a bug, than that's a serious one.
     
  7. rickdini

    rickdini

    Joined:
    May 19, 2013
    Posts:
    1
    Hi, did you ever reach a solution with this? I'm about to make a game that requires perfectly seamless audio loops. This worries me!
     
  8. Adam Shaw

    Adam Shaw

    Joined:
    Apr 17, 2013
    Posts:
    2
    I'm having the same problem. Audio is ticking when loops restart and "gapless looping" is always grayed out as an option. I've heard that the solution is to set the audio format to mpeg, but that doesn't seem to be one of my options right now with version 4.1.2f1.
     
  9. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    988
    I haven't really worked with standard looping of clips, so I can't comment on that, but you can loop seamlessly using playscheduled
     
    Last edited: Aug 6, 2013
  10. Adam Shaw

    Adam Shaw

    Joined:
    Apr 17, 2013
    Posts:
    2
    After banging my head against the wall for a while I figured out that the reason -my- clips were popping had to do with the sample rate. Apparently 44.1 kHz good, 48kHz bad.
     
  11. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,384
    Yeah I've found that playing with sample rates and compression can have different effects on the tick noise that a 'gapless' loop track has. It also changes when it's on iOS as opposed to the editor etc... it's annoying and probably is a bug that needs fixing.
     
  12. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,288
    If you have an audio clip that on iOS is converted into an mp3, and the mp3 is a multiple of frame size, and it pops, then submit a small test app as a bug.
     
  13. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,384
    What do you mean by this?
     
  14. henrypuspurs

    henrypuspurs

    Joined:
    Feb 7, 2013
    Posts:
    5
  15. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,288
    MP3 files break their audio up into frames, each of which is something like 1800 bytes long. (I forget the exact size, I know it's not 1800). For a given sample rate, each frame has a certain size in seconds of audio. If your mp3 clips is not a multiple of this time, then you'll have some empty space in the end of the last frame. This empty space will prevent your clip from looping seamlessly. (Now I come to think of it, I think they audio duration is fixed, and the frame size in bytes varies according to sample rate. A 128kbps clip has a frame size of 417bytes, the first 4 of which are header.)
     
    moonjump likes this.
  16. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    411
    Sure, just use WAV or OGG.

    You cannot loop an mp3 in Unity.

    (I don't know why Graham's answer is so staggeringly complicated. It's utterly trivial to loop an mp3 - any number of simple pieces of software does that, from other game engines to trivial audio players, etc. It's "nothing." It just happens that in Unity you can not loop mp3s. To loop audio in Unity just trivially convert first to OGG or WAV then drop that file in Unity. Nothing to it.)

    (ALSO NOTE GRAHAM: what you say is quite incorrect dude: if you magically guess a "clean" frame size to import in to Unity, it does not help because Unity re-does the sizing itself, anyway, and it will again break and have a gap. You can see any number of posts about this online. Note that there are any number of trivial tools available to "fix" a "matching frame size" for you regarding mp3 files. This simply does not work with Unity. You simply, cannot, loop an mp3 in Unity. It's no big deal and it's that simple.)
     
    Samacvuk likes this.
  17. jmasinteATI

    jmasinteATI

    Joined:
    Jul 14, 2015
    Posts:
    7
    Like @Fattie says, use wav or ogg instead of mp3. I ran into the same thing. Exporting to wav fixed it.
     
unityunity