Search Unity

Audio Audio slow down and crackling.

Discussion in 'Audio & Video' started by artaka, Jul 31, 2019.

  1. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    I'm experiencing issues with audio where it slows down and starts crackling at random times both inside the Editor and the Standalone Player. It happens even if I simply preview the audio file in the Inspector. I tried switching my audio drivers from "NVIDIA High Definition Audio" back to Windows 10 "High Definition Audio Device" but that didn't seem to make any difference.

    Anyone know why this could be happening and how I can fix it?
     
  2. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    bump...
     
  3. nickferns2727

    nickferns2727

    Joined:
    Aug 5, 2019
    Posts:
    1
  4. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    Anyone have any suggestions regarding this issue?
     
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    What does random mean? Does it work normally for 5 minutes and then crackles for 1? Is random but semi regular?

    Does changing the latency settings change anything?
     
  6. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,304
    Not a clue.

    What version of unity?
    What platform?
    What kinds of audio files are they?
    Is the sample rate of unity the same as the sample rate of the audio files?

    Create a new project for testing, drag one of the problem audio files into the project and preview it a bunch of times. Is the problem still there?
     
    Last edited: Oct 26, 2019
  7. maxmitchelll

    maxmitchelll

    Joined:
    May 19, 2019
    Posts:
    7
    I've been experiencing (what I believe to be) the same problem as OP. For me, it tends to occur after extended usage in Play mode, or extended play of a Standalone build. It's not super common, but also an unacceptable bug due to how much it distorts the audio. What's most concerning is that I've had Alpha testers report this same problem to me after playing the build on their PC, indicating that it's not an issue local to my computer. Additionally concerning is that this thread is the only one I've seen addressing this issue.

    To give more information per another users response:

    I'm using version 2019.3.14f1
    Platform is PC (Windows is what I use)
    Audio files are a mix of .mp3 and .wav. (although, the bug, when it occurs, happens across the board and distorts all the audio in the game (music, sfx, etc.))
    Audio file sample rates are set to Preserve Sample Rate (which is the default. I didn't change any settings for these audio files from the default per compression, load type, quality, etc.)

    Did anyone here ever find a solution to the bug or learn anything more about this issue? If this thread is dead I may make a new post regarding this issue, since it seems fairly unaddressed as far as I can tell.
     
  8. nocanwin

    nocanwin

    Joined:
    May 7, 2009
    Posts:
    176
    Maybe it's related. I had a similar issue, but just in the Editor(2019.4) AFAIK. Slow preview w/ crackling. In Project Settings > Audio > DSP Buffer Size. If I have it set to Best Latency then I get the issue. Any other setting doesn't cause the issue.
     
  9. zackblack

    zackblack

    Joined:
    May 17, 2015
    Posts:
    76
    I'm getting this on a standalone (release) build from Unity 2020.3.15f1 on Windows 10. The game will run perfectly normal and then after about 5-10 minutes of play, all game audio will start to "crawl" at about 1/2 to 3/4 speed with lots of popping and crackling. This will continue for a few minutes and then clear up. Anyone else have the same issue or a solution?
     
  10. kwikdev

    kwikdev

    Joined:
    Jun 13, 2013
    Posts:
    31
    Seeing this in the Editor a LOT. Using 2020.3.21f
     
  11. unity_8E406B1CD4DF43D4F349

    unity_8E406B1CD4DF43D4F349

    Joined:
    Sep 3, 2021
    Posts:
    1
    Thank you!! I solved it this way.
     
    Fenikkel likes this.
  12. k0rt4

    k0rt4

    Joined:
    Mar 19, 2013
    Posts:
    4
    This also solved it for me (Unity 2021.3.0f1) by just changing from "Best Performance" to Default and back to "Best Performance" again...I'm concerned though, that the issue could come back at any time on a build >:0
     
  13. officialkoreanjesus

    officialkoreanjesus

    Joined:
    Apr 19, 2022
    Posts:
    3
    If there is speed or crackling noise issues, its usually a sample rate mismatch. Might have to re-render the audio at the project's bitrate
     
  14. ChickenVegetable

    ChickenVegetable

    Joined:
    May 3, 2020
    Posts:
    87
    Thanks for the replies, I will look into these options
     
  15. BrianKesecker

    BrianKesecker

    Joined:
    Feb 5, 2021
    Posts:
    2
    Experienced this same behavior using version 2021.3.8. Choppy rendering and audio crackling, not in the editor, but only in the build output. I tried a number of things described on this thread (and beyond), but what I found to fix the issue was changing the OS native resolution from 3840x2160 to 1920x1080 (Windows). Also, the machine I was testing on was a laptop, so the power was less than my usual desktop development machine.

    Now the new problem, for me, is how to detect high (or scaled up) resolutions and provide the customer some choices when running the game. Thanks everyone for sharing your experience with this issue.
     
  16. audiovideoserviceS

    audiovideoserviceS

    Joined:
    Aug 29, 2022
    Posts:
    1
    A bad configuration of your sound card, that includes equalisation, audio quality (24, bits, 16 bits, etc…) and sampling resolution.

    I could be caused by dirty speakers too, so cleaning with compressed air could be the solution.

    Finally a bad mounted speaker could be the reason, as they vibrate, they will slowly unacrew, even if they are pasted with some kind of adhesive they will loosen with the years and years of deadmou5e, so open your pc and rescrew them if you know ehat you're doing, other wise, hand your computer to a teky pearson.

    I know this is a late response, but I hope it is helpful for new people coming here for solutions.
     
  17. immerVR

    immerVR

    Joined:
    Jan 23, 2020
    Posts:
    6
    For Unity 2021.3.10f1, I can confirm the same behavior in Windows Editor. On Audio - DSP Buffer Size "Best Latency", this happens. Changing it to "Good Latency" it seems not to happen anymore. Sound device is onboard Realtek Audio (showing as Dell/AMD F17/19 (Ryzen2/3, TR/2) HD Audio Controller in SiSoft Sandra) on AlienWare mainboard (model: 0TYR0X) from 2021. My desktop and game frame rate runs at 144 Hz.

    The audio file used is an mp3 file, which as audio clip I tried both "Decompress on Load" with preload and streaming. Compression format is set to Vorbis, Quality 100, Preserve Sample Rate which is 44100 Hz, Stereo.
     
    Last edited: Nov 30, 2022
  18. LGW_DesertEagle_PWN

    LGW_DesertEagle_PWN

    Joined:
    Jul 25, 2019
    Posts:
    4
    Experienced this in 2019.4.36f1 in Windows 10 Editor. Happens with the "Best latency" setting as well. Changing it to "Best Performance" also resolved this for us. I am running a Legion Y740-17IRHg using Realtek Audio on 64 bit Windows 22H2 19045.2486.
     
  19. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    210
    This same issue happens on 2021.3.27f1 and 2022.3.4f1. Changing to "Default" from "Best latency" fixes the bug right away!
     
    Last edited: Jul 20, 2023
    BrianKesecker and Verne33 like this.
  20. Verne33

    Verne33

    Joined:
    Apr 12, 2020
    Posts:
    32
    Edit: On further exploration, audio playback via Best Latency seems to be broken for PC builds. Audio will crackle in a build and Audio clip playback will be messed up in Editor. Default (1024 bitrate) works fine.

    Same here. For anyone who wants "Best Latency" while avoiding this issue in Editor, you can adjust audio settings at runtime, such as:

    Code (CSharp):
    1. AudioConfiguration audioConfig = AudioSettings.GetConfiguration(); //Thanks kodra_dev for pointing this out
    2. audioConfig.dspBufferSize = 256; //  This is the buffer size for "Best Latency"
    3. AudioSettings.Reset(audioConfig);
     
    Last edited: Aug 18, 2023
    BrianKesecker and manurocker95 like this.
  21. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    78
    I'm having this problem too (using Unity 2022.3.5), here's what I'm seeing:

    If I use OnAudioFilterRead() on any component on the scene, music will crackle when going to the next scene (in a published build). As soon as I delete the component from the scene I can switch between scenes without any crackling issues in the music playback.

    I tried creating the component that uses OnAudioFilterRead() in runtime and destroy it as soon as it's no longer needed - the problem remains though (even when I destroy usgin DestroyImmediate).

    I tried all the tricks recommended on this thread, but nothing gets rid of those crackling sounds on mobile if the scene ever had a component that used OnAudioFilterRead().

    I would love to monitor the audio data from the Audio Mixer instead of a component using OnAudioFilterRead, but I can't find any documentation on how to do this. I wonder how the meters and faders in the Unity editor are implemented...
     
  22. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    416
    I might lack some context here, but are you sending you AudioSources to a mixer group?
     
  23. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    78
    Exactly. And I can't find any other way to monitor the sound data other than OnAudioFilterRead (which results in crackling after its done)...

    Is there any way to tell Unity that I'm done with OnAudioFilterRead so that it can go back to the (non crackling) default state? Destroying the object that contained the component calling OnAudioFilterRead() does not do the trick...
     
    Last edited: Aug 14, 2023
  24. kodra_dev

    kodra_dev

    Joined:
    Oct 31, 2022
    Posts:
    108
    Still a problem in 2022.3.4f1 (3 years later lol). Sounds crack in editor preview when DSP buffer size is "Best Latency".
     
    kloot likes this.
  25. kodra_dev

    kodra_dev

    Joined:
    Oct 31, 2022
    Posts:
    108
    By the way you probably want to set it like this:

    Code (CSharp):
    1.  
    2. AudioConfiguration audioConfig = AudioSettings.GetConfiguration();
    3. audioConfig.dspBufferSize = 256;
    4. AudioSettings.Reset(audioConfig);
    5.  
    Otherwise you'll overwrite all the other settings with default values.
     
    Verne33 likes this.
  26. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    kodra_dev and kloot like this.
  27. kodra_dev

    kodra_dev

    Joined:
    Oct 31, 2022
    Posts:
    108
    kloot likes this.
  28. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    78
    True... And also - what are the chances no one would have submitted a pull request for this (and endless other ancient bugs) years ago, had Unity been an open source project...
     
  29. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    416
    OAFR does lack some love, the fact that it's not "burstable" and subject to garbage collection makes it an less-than-perfect tool (to say the least) for this kind of audio work.

    There are some internal project aimed at improving this, I hope that someday they will get enough traction to be implemented!
     
  30. Verne33

    Verne33

    Joined:
    Apr 12, 2020
    Posts:
    32
    I think many of us doing audio-centric work are just wondering if we can expect any significant Audio feature/tool upgrades in the foreseeable future. Honestly I am afraid we already know the answer, so it pains me to even bring it up. But it seems it has been around 7 years since any major upgrades were made. Meanwhile Unreal has all sorts of neat stuff including metasounds. At this rate, any new dev who wants to work heavily in audio will be on an on-ramp to switching to Unreal at some point in their career.
     
    kloot likes this.
  31. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    78
    Sadly yes... Either Unreal (where things appears to actually get fixed over the years), or Godot where we have a chance to fix them ourselves.

    If Unity would only devote resources to fix at least some of the ancient bugs and obvious shortcomings brought up in these forums... I think we're all so fed up with Swiss cheese at this point that it's not even funny any longer.
     
    Last edited: Aug 18, 2023
  32. tetto_green

    tetto_green

    Joined:
    Dec 22, 2015
    Posts:
    35
    Solved the issue! Thanks!