/** * Constructors */ public SmoothSoundManager(SmoothSoundPlayer soundPlayer1, SmoothSoundPlayer soundPlayer2) { _channel1 = soundPlayer1; _channel2 = soundPlayer2; _clips = new List<DriveSound>(); }
private void Fade(float deltaTime) { if (_faderMomentum >= 0.0001f) { _fader += _faderMomentum * deltaTime; // If channel2 is completely faded in, swap channel1 and channel2 // and stop playing the now muted sound if (_fader >= 1.0f) { SmoothSoundPlayer temp; temp = _channel1; _channel1 = _channel2; _channel2 = temp; _channel1Sound = _channel2Sound; _channel2.Stop(); // If theres a sound waiting to be played if (_soundWaiting >= 0) { _channel2.PlaySound(_clips[_soundWaiting]); _fader = -1.0f; } else { _fader = -1.0f; _faderMomentum = 0.0f; _channel2Sound = -1; } } } }