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

Question I have a terrible problem with sound delay, but that's not all.

Discussion in 'Audio & Video' started by lubloczek, Jul 3, 2023.

  1. lubloczek

    lubloczek

    Joined:
    Jul 3, 2023
    Posts:
    2
    The game I'm currently making has a huge problem with audio delay. I want the sounds of jumping to play instantly after the player jumps, but they have untolerable sound latency, maybe not to a degree that makes the game unplayable but still enough to mildly infuriate me.

    Before you ask: yes, I did try to change order of tasks in the scripts (I tried to make the sound play first and then make the player jump) and it didn't work. Then I tried to switch the DSP buffer size to "Best latency" (as every tutorial suggested) and it removed the delay, but whenever it's set to "Best latency" this annoying audio crackling occurs every second, sometimes even multiple times per one AND ALSO the music randomly slows down and speeds up again for no reason. I have totally nothing that could cause this in any of the scripts. I tried to make an actual build of the game and it didn't help. Desperately wanting to fix this issue, I ran the game on a different computer. Didn't help either. Also no, the clicking doesn't occur just at the beginning and the end of each clip, but in the middle as well.
    In case it's important, the game is intended for Windows and I'm using unity 2021.1.3f1.

    What should I do?
     
  2. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    283
    Are you using Play() or PlayOneShot()? The PlayOneShot() function is useful for playing a sound immediately, without interrupting a sound that's already playing on the same AudioSource.

    Also if you're using any audio effects (reverb, echo, etc.), you could try disabling them to see if they're causing the issue.

    If you're on Windows 11, some latency can also occur because of the OS, see this post: https://forum.unity.com/threads/windows-audio-latency-mystery.1398793/#post-8806588

    Finally what's the import setting of you sound? Using "Decompress on Load" can minimize latency for small audio clips.

    I hope this helps!
     
  3. lubloczek

    lubloczek

    Joined:
    Jul 3, 2023
    Posts:
    2
    I think it worked (disabling "Signal enhancements" fixed the music issue even in "best latency"), but also didn't. I tried to run it on a different computer to test if it works on other OS's and... I kinda can't. Windows 11 thinks it's a virus. I mean, I can open the game when I click the more info button, but the mere fact that this pops up may be suspicious for people.

    In case it's important, when I click the more info button the warning only says:
    Application: *game name*.exe
    Developer: Unknown Developer
    (it may not be exactly that, as I'm not using the English version of Windows, but you get what I mean)
     
  4. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    283
    I did some research and I think this pop-up shows up because the app has to be signed with a certificate (a bit like https trusted websites). This is a bit out of my league to be honest...

    Did it do that before? Maybe this happens because you'd be using a debug build or because the game is accessing some restricted system API... I really don't know, sorry...

    It seems like you can self-sign you executable (with SignTool, using a selfsigned certificate) but I'm not sure if that's a solution more than a workaround.