Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Gapless looped mp3 in iTunes, "cracks" while looping in Unity

Discussion in 'Audio & Video' started by Julez1233, Mar 17, 2015.

  1. Julez1233

    Julez1233

    Joined:
    Mar 2, 2015
    Posts:
    3
    Hi Guys,
    I have mp3 file, which loops absolutly perfect in iTunes, "cracks" in Unity when it restarts, because somehow the loop isn't perfect anymore.
    Had anybody of you a similiar problem or even a solution for this?
    Thanks a lot,
    Julian
     
  2. BenRawlesMusic

    BenRawlesMusic

    Joined:
    Jan 11, 2013
    Posts:
    165
    Hi Julian,

    Unfortunately mp3 files don't tend to loop properly due to a short silence which is added to the start of the clip during export (iTunes most likely crossfades when looping to hide the imperfection). Ogg format is a much better choice for a seamless loop :)

    If you don't have access to the raw file, I can fix the loop for you and send an ogg version if that would help?

    Ben
     
    Julez1233 and Parallaxe like this.
  3. Julez1233

    Julez1233

    Joined:
    Mar 2, 2015
    Posts:
    3
    Yeah, that was exactly the Problem.
    I chose .mp3 because it's compressed. But you can make unity to compress your file (.wav in my case) to mpeg and also toggle "gapless looping".
    I also found an solution with a tool which "cut off" the small overhead of a mp3.
    But I preferred first one.
    Thanks.
     
  4. metaphysician

    metaphysician

    Joined:
    May 29, 2012
    Posts:
    184
    yeah, basically the main issue here is that MP3 is so old it predates sample based thinking and is only concerned about length in terms of video frames. so any mp3 that has a length which does not exactly correspond to a frame gets extra silence added until the length equals a frame. thus the skipping, and the slim chance that you might very occasionally manage to get the boundaries close enough to a frame length so that they work.

    the solution if needing to use MP3 is to calculate the sample length of the compressed vs the uncompressed file and either end the file early, or do like Compuphase does - move the end of the file to the end of the sound and then start the sound later on. and it's by no means a silver bullet - different hardware/OS combinations on mobile devices will get you different results. doing it in code is a bit more reliable.

    scott