I’m a newbie using Javascript in Unity 5.4.1. If I set the volume of my music to be very quiet (but not off), when I start the next level, the music will slowly get louder if I don’t move my character (rolling ball).
As soon as I hit an object with the ball, the music volume drops back down - as if having a sfx play will cause the music to drop back down.
My AudioSource is set to 2D. My listener is on my Main Camera. Here’s a snapshot of the inspector on my music.
The problem was occurring by itself. I don’t have any code that adjusts the music volume.
It didn’t occur to me to turn on the slider (normally it’s hidden). After reading Cynikal’s comment, I turned on the slider. Unfortunately (or maybe fortunately), I can’t repeat this bug anymore. Late last night (after asking the question), I went thru all my levels and reconnected my music audiosource to the game object with the slider.
Maybe that fixed the problem since I can’t get to happen now. If it does happen again, I’ll definitely turn on the slider and see if it moves.
I had the same issue and this seems to be a bug in Unity. This only happens if the music volume is set to very low. Only conclusion I can think of is this is a bug in the way Unity’s compressor logic works.
Unity seems to have some audio compressor logic to make sure the audio levels are at a decent level. So it will raise the volume to an appropriate amount and then “duck” them so they don’t clip over the maximum (which would sound very bad). For example, say you have lots of audio sources playing at volume of 1. If they all play simultaneously Unity automatically adjusts their volume or applies a compressor so the waveform won’t clip.
I think there is a bug in the way Unity does this with music over the long run; this compressor no longer operates on a short time scale and seems to very gradually “creep” the music volume upward, until a sound effect is played, at which point it “ducks” the music even though it never really needed to do that when the music was set to full volume.