Setting the volume of my audiosource to 0 does not mute it.

Hey everyone, first time posting here, so please forgive me.

I attached an audiofile to my main camera. The audio is set on PlayOnAwake so that all works fine.
While implementing an audioslider in my menu I found out that I couldnt mute the audio. Neither with the mute button, nor with setting the volume to 0. Changing the volume does infact change the volume, but only between loud and very loud.

Thanks in advance! Any help/ideas are appreciated.

Double check that you don’t have a duplicate of that audiosource playing alongside the one you are editing. Also check it’s not enabled for 3D sound… Volume 0 should still mute the audio even with 3d sound but it’s worth ruling out!

2 Likes

@Docaroo has probably already found the problem.

However you should keep in mind that muting an AudioSource using only the volume not actually save you any performance!

The “.mute” property will internally also exempt the AudioSource from mixing, thus saving you performance.
Setting the volume to 0 however will not.

An AudioSource with volume=0 will internally still play, and cause the audio system to still include it in the mixing calculations, even though all the samples it outputs will be multiplied by zero.

That will become a drain on performance rather quickly. So if you have some stuff where the volume is controlled by some user setting (like “sfx volume” in many games) make sure to use the mute property.

Are you sure that is also the case in builds? In the testing I’ve done even a “muted” audiosource keeps the mixers active and runs through any effects … it looks like it has the same impact as a volume=0 source.

Although, when it comes to building the project these things are all optimized so I wonder how muting and volume=0 translates into the build?

Yes it is the case also in builds, but it might not be noticeable until there are rather high numbers of audiosources
You should see impact on this reflected in e.g. DSP CPU % in the profiler

I might not have been clear.

I have a script that lowers the volume of the music after clicking a button. And that works just fine. After 1 second (since I made it so) the sound is muted (and the song is stopped so that it wont play silently).
However I linked the audiosource to a slider. Changing that slider does nothing. And even after selecting the Audiosource and changing the slider provided by Unity in the Inspector only changes the volume from loud to less loud, but not from loud to muted.

Oh my god!

as @Docaroo said, I had another AudioSource playing.
thanks for making me check=) it works now=)

Haha that was a bit of a hail mary call that one but just goes to show it’s always worth checking absolutely everything just in case!

Glad you solved it!

I have the same problem, but no two audio sources. Changing the audio volume programmatically does not change the audio source volume unless the component is disabled and renabled.

Solved: Changing audio source volume does not work if the game is paused (time scale 0).