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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Trying to get clear On Unity 5 Audio basics for Audio Clip and Audio Source

Discussion in 'Audio & Video' started by metaphysician, Mar 30, 2015.

  1. metaphysician

    metaphysician

    Joined:
    May 29, 2012
    Posts:
    190
    Greetings! what an awesome thing - our own Audio forum. about &*^%$ time!

    anyway - i apologize if this has been asked or covered before - maybe it could be stickied or saved for future newbies?

    1. Audio Clip - Load In Background - I think I've got a pretty good handle of this, just double checking my assumption. This means the audio loads outside of the main program loop which helps if the game is bogging down due to loading a bunch of AudioClips at one time. Am I right on this?

    2. Audio Clip - Preload Audio - what does Preload Audio do? i would have thought it would not play an AudioClip at all if i don't have that checked, and I was using it on an AudioSource set to Play On Awake. but that's not the case - the sound plays immediately in either case. what the difference between leaving it on or leaving it off? maybe the PlayOnAwake option automatically calls LoadAudioData() when enabled?

    3. Audio Source - Reverb Zone Mix - This one I'm completely mystified about. What the heck does it do? My guess is that it sends some of its audio to a Reverb Zone to act as a master send of some kind? Or maybe it means that it will send a certain amount of its signal to any nearby Reverb Zones? which means if it's set to zero the Audio Source won't have any reverb characteristics? Just curious here...

    any expert care to enlighten me? i'm in the process of making a pretty detailed comparison tutorial video on the differences between Unity 4 and Unity 5 (leaving out bigger things like the Mixer and the Plugin effects (which is awesome)) and would like to have my information as accurate as possible. thanks in advance!
     
    CAKE1 and rakkarage like this.
  2. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Interested in these answers too.
     
  3. gregzo

    gregzo

    Joined:
    Dec 17, 2011
    Posts:
    795
    Hi!

    1. Load in background: yep, this will load the clip on a background thread. A really nice addition: no need to pause gameplay to load new sounds.

    2. Preload : loads the audio data before the first Awake call in your scene. Note that clips which are preloaded cannot be unloaded. Now, if you call Play on a clip which isn't preloaded nor loaded yet, Unity will load it for you. You might not notice it in the editor ( which will preload clips anyway ), but try to play a long clip set to Decompress On Load in a build and you'll notice your framerate takes a hit.

    3. Well, simply a dry/wet mix for reverb managed by a reverb zone, nothing mysterious there.

    I hope it helps,

    Gregzo
     
    CAKE1 likes this.
  4. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Gregzo, more questions about #1.

    1) Sounds like Load in background is basically "load async", right?
    2) Is this an alternative to Resource files?
    3) How are the sounds unloaded?
    4) I assume the clip is only loaded when requested to play?

    Thanks!
     
  5. gregzo

    gregzo

    Joined:
    Dec 17, 2011
    Posts:
    795
    1) yep.
    2) kinda, except you get metadata on the audioclip before loading it. So it's actually more convenient...
    3) With the UnloadAudioData method. If the clip was created at runtime, using Destroy is still necessary.
    4) yes, or when LoadAudioData is called, or when preload is true.
     
    jerotas likes this.
  6. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Excellent info, thanks Greg!
     
  7. wihu

    wihu

    Joined:
    Nov 22, 2012
    Posts:
    25
    Hi, I want to know official answer to this question:
    if audio preload data is checked and load type is set to streaming, which one is cancelled out?
     
  8. 8bitRick

    8bitRick

    Joined:
    Nov 18, 2013
    Posts:
    11
    I don't have the official answer but I am running into a similar issue/question.
    Does "Load in Background" make any sense if I choose "streaming" as the play type? I am assuming it does not make sense. In practice (Unity 5.5.0p4) it appears that "Load in Background" is winning. There is a long delay before it plays my music. So I'm turning "Load in Background" off for all music and setting the load type to streaming.