protected void updateFade ( float time ) { if ( _fadeMode == FadeMode . NONE ) { return ; } float alpha = Math . min ( ( _fadeElapsed += time ) / _fadeInterval , 1f ) ; _source . setGain ( _gain * ( _fadeMode == FadeMode . IN ? alpha : ( 1f - alpha ) ) ) ; if ( alpha == 1f ) { if ( _fadeMode == FadeMode . OUT ) { stop ( ) ; } else if ( _fadeMode == FadeMode . OUT_DISPOSE ) { dispose ( ) ; } _fadeMode = FadeMode . NONE ; } }
Updates the gain of the stream according to the fade state .