Search Unity

Popping at the end of sound files

Discussion in 'Audio & Video' started by gabrielhauser, Dec 2, 2015.

  1. gabrielhauser

    gabrielhauser

    Joined:
    Dec 2, 2015
    Posts:
    1
    Recently we upgraded to Unity 5.2 (from 4) and now I notice that some sound files playing have a audible "pop" at the end. The pop, however, is not preset in the sound file itself - just when it's played in the editor. Not all sounds though. Just some. Any idea what's going on or what to do? I have them as .wavs and auditioning them through Unity yields no pops. Only running the game in editor.
     
  2. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    We saw this problem after upgrading a project from Unity 4 to 5 as well. Interested in hearing why this happens and how to fix it.
     
  3. Apoll0

    Apoll0

    Joined:
    Jun 11, 2015
    Posts:
    16
    Same issue in Unity 5.3
    Temporary solved by changing Load type to "Streaming"
     
  4. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    216
    Here as well. Sound file is zeroed at the end, doesn't matter what format I use or whether it's decompressed on load/streamed etc, still pops.
     
  5. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    Thought I was going insane. I've been seeing this as well, exactly as you described it, though I don't think I noticed it as far back as last December.
     
  6. soundsbyme

    soundsbyme

    Joined:
    Feb 22, 2017
    Posts:
    2
    Same here.
     
  7. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    If you can reproduce the issue, Unity Technologies would probably be interested to look at it if you submit a bug-report, following their guidelines in this document.
     
  8. soundsbyme

    soundsbyme

    Joined:
    Feb 22, 2017
    Posts:
    2
    I believe I can reproduce it with a new project, will take a look at that.
    For now, the problem is solved (or rather, worked around) by using ADPCM import settings.
     
    Peter77 likes this.
  9. imphenzia

    imphenzia

    Joined:
    Jun 28, 2011
    Posts:
    413
    Interesting, and annoying.

    I am experiencing the clicks at the end of some audio files (confirmed to be at 0 volume faded out at the end) too. If I resample from 44.1 kHz to 48 kHz in an external editor and re-import the audio the problem goes away for that audio file but not sure if that is just a coincidence because other 44.1 kHz audio files are fine. For me changing from "Decompress On Load" to either "Streaming" or "Compressed In Memory" works around the problem... but I would rather solve it =)

    Was there ever a bug reported for this issue?
     
  10. AssembledVS

    AssembledVS

    Joined:
    Feb 23, 2014
    Posts:
    248
    Did you ever figure out what was causing this issue?

    I think that I'm having the same exact problem. This only happens when using "Decompress on Load." It also happens on sound clips that are at zero volume at the end of the clip, even before the end of the clip, but it doesn't seem to happen to all sound clips. This also happens in a blank project with just an audio source and a sound firing on awake. I also tried on another computer with a different sound card, same issue.

    "Streaming" or "Compressed In Memory" seems to completely fix it. Using "Decompress on Load" and increasing the bitrate to 48 KHz seems to dampen the popping sound, but not get rid of it. Using lower rates seems to exacerbate the issue. Playing around in the project's audio settings does not fix it.
     
    Last edited: Jun 8, 2019
  11. Battenberg-Software

    Battenberg-Software

    Joined:
    Nov 1, 2013
    Posts:
    18
    I came across this problem when creating audio clips manually from waveforms (e.g. sine waves, square waves) to generate sound effects. At 44.1kHz, however much silence I added at the end of the wave, there was always a click when the audio clip finished.

    I solved it by ensuring there was also silence at the beginning of the wave. Literally one sample will do - it just has to be 0 at the start. I can't explain why - maybe the audio clip loops back to the beginning for a single sample when it finishes, but either way it solved it for me.
     
  12. LEDWORKS

    LEDWORKS

    Joined:
    Mar 14, 2012
    Posts:
    9
    I keep running across this issue and can confirm the cause is an audio clip starting at something other than 0 volume. It is strange how the popping is heard at the end of the clip and nothing in other applications, even the preview in Unity.
    The fix is to edit the offending audio clip to start at 0 (in both left and right channels) and have a small gap of silence before the wave starts.


    * I suspect its caused by the compression as playing the preview is likely an uncompressed wave, that explains why we don't hear it there.
     
    Last edited: Dec 12, 2019
    emredesu and -chris like this.
  13. friuns3

    friuns3

    Joined:
    Oct 30, 2009
    Posts:
    307
    that hack fixed it Thanks. I think somebody need to make bug report or we will witness this bug another 5 years :D
     
    Last edited: Apr 11, 2020
  14. ron-bohn

    ron-bohn

    Joined:
    Oct 5, 2015
    Posts:
    316
    mp3's will cause popping in unity (actually a delay before it starts playing causing a popping sound). Don't use mp3's! If you do, at least fade them in and out with scripting as a work-around, or better yet, make sure the file is a wav or ogg.
     
  15. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    According to this answer, the issue seems to be related to .mp3 assets only. Why don't you use .wav files instead?
     
  16. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    i have no idea why mp3 format is so ingrained in common unconsciousness that ogg/vorbis - which has better quality/compression ratio, (supposedly) sounds better in lower bitrates and - most importantly - doesn't suffer this frame rounding error - isn't even mentioned in cases like these
    so that's worth a try
     
  17. erdostamasa

    erdostamasa

    Joined:
    Mar 28, 2020
    Posts:
    32
    For future reference,I'm experiencing the same problem with a Vorbis file. Tried every Load type/Compression format combination, the clicking is the same.
    The clicking is only happening in Unity.
     
    mrGramuel likes this.
  18. Wasplay

    Wasplay

    Joined:
    Jun 2, 2018
    Posts:
    46
    I use .wav but the problem still happens when the sound file doesn't start at "0" volume
     
  19. potatosallad3

    potatosallad3

    Joined:
    Sep 10, 2019
    Posts:
    31
    .ogg/vorbis files absolutely experience this bug, wavs as well. Making sure there is no signal at the very start of the file seems to avoid it.
     
    jjek_unity, mrGramuel and -chris like this.
  20. Spirit_Warrior

    Spirit_Warrior

    Joined:
    Jan 1, 2020
    Posts:
    16
    Still happens in 2023. I have some .wav sounds and still POPs when finish the sound. The even have fadeout but still happens, only in Unity, in other players or audioeditors doesn't happen.
     
  21. hid_

    hid_

    Joined:
    Apr 5, 2021
    Posts:
    10
  22. PasMol

    PasMol

    Joined:
    Feb 5, 2016
    Posts:
    13
    The problem is still relevant.
    The sound click disappears if the beginning of the sound wave is reduced to zero:
    before.png after.png
     
  23. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,442
    This is traditionally good advice. The first sample and the last sample of a sound should be zero to avoid any pop (because think about it, the speaker position is at zero before the first sample, and wants to return to zero after the last sample). You showed a closeup of how to fix the beginning of a sound clip. People should also do the end of the sound clip the same way, fading to zero or otherwise massaging the sound so that it happens to be at zero at the last sample.

    Unfortunately, the weak sampling algorithm Unity uses can skip samples, and any time you're decoding from a lossy compressed audio format like mp3 (which is the vast majority of sounds packed into a mobile Unity game), the samples can be changed to suit the compression.

    The answer is to have a zero for several samples at the beginning (long enough to force compression and sampling to see a real zero), and many samples at the end (long enough that any pitch bending effects are also forced to see a real zero when the play position is nearing the end). I generally use about 0.1 seconds worth of purely zero tail, and a little less at the head.
     
  24. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Even at zero for .1s at the beginning of the sound and the end, there's still a small distinct pop at the end of a specific .ogg file. Extremely weird.
     
  25. Xyloven

    Xyloven

    Joined:
    Feb 22, 2021
    Posts:
    8
    I had the same problem, but after deleting the audio reverb filter on my object and changing it to an audio reverb zone the popping is gone. Maybe it will help someone
     
  26. Donderbos

    Donderbos

    Joined:
    Oct 10, 2015
    Posts:
    2
    This was the only solution that worked for me! Thanks @Xyloven
     
  27. saharsh1223

    saharsh1223

    Joined:
    Jun 20, 2021
    Posts:
    3
    Simple fix, just use AudioSource.PlayOneShot(AudioClip clip); instead of AudioSource.Play();

    Nothing else is required.
     
    Last edited: Jan 13, 2024
  28. w62534410

    w62534410

    Joined:
    Dec 15, 2023
    Posts:
    2
    A little definite pop may still be heard at the conclusion of a particular.ogg file, even at zero for the.1s at the beginning and end of the sound. really strange