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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Audio Can an Audio Clip asset have both "Load in Background" and "Streaming" at the same time?

Discussion in 'Audio & Video' started by burrpuzzle, Apr 25, 2022.

  1. burrpuzzle

    burrpuzzle

    Joined:
    Dec 21, 2015
    Posts:
    4
    I've been reading about Audio import settings and wondering about the question in the title. The Unity Audio Clip manual is pretty good and does not seem to contradict this mix of settings.

    However on skimming through additional resources on the topic, I found a few guides like this one and also this one that, each had tables proposing audio import settings, and always mark "Loading in Background" as N/A when mixed with "Streaming" - I'm reading this as not possible.

    In my own tests in Unity 2020.3, I've tried playing Audio Clip asset set to Streaming WITHOUT "Load in Background", and then WITH "Load in Background" and profiled it:
    - Streaming on, load in background off: I can clearly see a CPU hitch when it is off, anywhere from 1.5 to 5ms CPU on my machine and current project depending on the size of the sound played as it is being read from disk.
    - Streaming on, load in background on: The original hitch almost completely disappears with the Load in Background setting is on, while still Streaming and read from disk, which I imagine is in turn playing the sound a bit late as it is loaded. In other words I can see the mix of these settings work.

    I'm trying to figure out then why some Unity guides refer to the mix of these two settings as something that isn't possible? What am I missing?
     
  2. JLF

    JLF

    Joined:
    Feb 25, 2013
    Posts:
    137
    Using Load in background stops the loading process from stalling the main thread, I assume with a asynchronous operation.

    when using streaming there’s generally nothing to load since it streams the data, loading the cpu instead of memory.

    I’m guessing what’s happening is that there is still a loading operation and that load in background is affecting it but because there’s nothing really to load it doesn’t make a significant difference.

    I wrote an article on this that you might find helpful: https://gamedevbeginner.com/unity-audio-optimisation-tips/#audio_load_types
     
    burrpuzzle likes this.
  3. burrpuzzle

    burrpuzzle

    Joined:
    Dec 21, 2015
    Posts:
    4
    Thanks for your response! And for the link. I will have to perform some more tests perhaps on an empty projects to make sure it isn't affected by anything else. The case I was referring to in the original post is part of an established project with a bit of overhead.