Category5.SoundClip.Update C# (CSharp) Method

Update() public method

Must be updated in game loop, required for real time calculations in our case it's only used to fade in and out songs failure to call update results in songs playing at constant volume.
public Update ( ) : void
return void
        public void Update()
        {
            if (Playing)
            {
                switch (effectState)
                {
                    case Effect.Normal:
                        clipInstance.Volume = volume;
                        fadevol = 1.0f;
                        break;
                    case Effect.FadeIn:
                        if (fadevol >= 1.0f)
                        {
                            fadevol = 1.0f;
                            clipInstance.Volume = volume;
                            effectState = Effect.Normal;
                        }
                        else
                        {
                            fadevol = ((float)((DateTime.Now - fadeTargetTime).Ticks)) / ((float)(fadeLength.Ticks));
                            clipInstance.Volume = fadevol * volume;
                        }
                        break;
                    case Effect.FadeOut:
                        if (fadevol < 0.0f)
                        {
                            fadevol = 0.0f;
                            clipInstance.Volume = fadevol;
                        }
                        else
                        {
                            fadevol = ((float)((fadeTargetTime - DateTime.Now).Ticks)) / ((float)(fadeLength.Ticks));
                            clipInstance.Volume = fadevol * volume;
                        }
                        break;
                }
            }
        }