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 Does playing audio sources with a volume set to 0 impact performance?

Discussion in 'Audio & Video' started by Infinite-3D, Jun 27, 2023.

  1. Infinite-3D

    Infinite-3D

    Joined:
    Jan 5, 2020
    Posts:
    37
    In my game, I have some looping audio sources constantly running, at 0 volume. I do this so that I can programmatically increase the volume when they're needed. Does keeping them running at 0 volume impact performance?

    For example, cars in my game have a looping audio source set to "Play on Awake" playing a motor sound. When the car isn't moving, this audio source has a volume of 0. When the car's moving, the volume gets increased so it's audible. I'm going to have a lot of these car objects in my scene, and I'm wondering if keeping all of these audio sources running even if they're inaudible is bad for performance.
     
  2. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    290
    TLDR; a silent sound is not free, but less expensive than an audible one.

    When a sound is considered inaudible, it is "virtualized". This also happens when there are too many sounds at the same time and some are excluded from the mix based on their priority.

    So when a sound is virtualized, it is only partially updated, in the sense that its position, speed, volume, etc. will still be computed but it won't be sent to the audio driver. This give a relevant performance boost as you get less voices to manage when mixing your final output.

    An easy way to save some CPU cycles would be to disable your AudioSource when it's not used, so your component Update() is not even called and the sound is not crunched by the engine.
     
  3. Infinite-3D

    Infinite-3D

    Joined:
    Jan 5, 2020
    Posts:
    37
    Thank you! This helps a lot.
     
    SeventhString likes this.