示例#1
0
 public void CancelFades()
 {
     m_fadeTimer.Enabled = false;
     m_fadeTimerState    = FadeTimerState.Inactive;
     m_entryFadeDelta    = 0;
     m_exitFadeDelta     = 0;
     m_exitFadeThreshold = 0;
 }
示例#2
0
 public void ImmediateFade(int durationInSeconds)
 {
     if (durationInSeconds != 0)
     {
         m_exitFadeDelta     = -1.0f / (durationInSeconds * ((float)1000 / FADE_TIMER_INTERVAL));
         m_exitFadeThreshold = Position + FADE_TIMER_INTERVAL;
         m_fadeTimerState    = FadeTimerState.Threshold;
         if (!m_fadeTimer.Enabled)
         {
             m_fadeTimer.Enabled = true;
         }
     }
 }
示例#3
0
 public void ImmediateFade(int durationInSeconds)
 {
     if (durationInSeconds != 0)
     {
         this.m_exitFadeDelta     = -1f / (durationInSeconds * 10f);
         this.m_exitFadeThreshold = this.Position + 100;
         this.m_fadeTimerState    = FadeTimerState.Threshold;
         if (!this.m_fadeTimer.Enabled)
         {
             this.m_fadeTimer.Enabled = true;
         }
     }
 }
示例#4
0
        private void fadeTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            switch (this.m_fadeTimerState)
            {
            case FadeTimerState.Inactive:
                this.m_fadeTimer.Enabled = false;
                break;

            case FadeTimerState.Entry:
                if (this.m_channelVolume >= 1f)
                {
                    if (this.m_exitFadeDelta != 0f)
                    {
                        this.m_fadeTimerState = FadeTimerState.Threshold;
                    }
                    else
                    {
                        this.m_fadeTimerState = FadeTimerState.Inactive;
                    }
                    break;
                }
                if ((1f - this.m_channelVolume) >= this.m_entryFadeDelta)
                {
                    this.Volume = this.m_channelVolume + this.m_entryFadeDelta;
                    break;
                }
                this.Volume = 1f;
                break;

            case FadeTimerState.Threshold:
                if ((this.m_exitFadeThreshold != 0f) && (this.Position >= this.m_exitFadeThreshold))
                {
                    this.m_fadeTimerState = FadeTimerState.Exit;
                }
                break;

            case FadeTimerState.Exit:
                if (this.m_channelVolume <= 0f)
                {
                    this.m_fadeTimerState = FadeTimerState.Inactive;
                    break;
                }
                if (this.m_channelVolume >= -this.m_exitFadeDelta)
                {
                    this.Volume = this.m_channelVolume + this.m_exitFadeDelta;
                    break;
                }
                this.Volume = 0f;
                break;
            }
        }
示例#5
0
 void fadeTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     switch(m_fadeTimerState) {
         case FadeTimerState.Inactive:
             // It shouldn't be running, so kill it
             m_fadeTimer.Enabled = false;
             break;
         case FadeTimerState.Entry:
             if(m_channelVolume < 1) {
                 // Increase the volume
                 if(1.0f - m_channelVolume < m_entryFadeDelta) {
                     // Will fmod cap it at 1 if a higher value is set, or does
                     // this need to be done to get it to set it when the value
                     // would be > 1?
                     Volume = 1;
                 } else {
                     Volume = m_channelVolume + m_entryFadeDelta;
                 }
             } else if(m_exitFadeDelta != 0) {
                 // Done with the entry fade, but there's an exit fade that needs
                 // to be watched for.
                 m_fadeTimerState = FadeTimerState.Threshold;
             } else {
                 // Done with the entry fade and there is no exit fade, so the fade
                 // timer is no longer needed.
                 m_fadeTimerState = FadeTimerState.Inactive;
             }
             break;
         case FadeTimerState.Threshold:
             // Waiting to pass the exit fade threshold
             if(m_exitFadeThreshold != 0 && Position >= m_exitFadeThreshold) {
                 // Start the exit fade
                 m_fadeTimerState = FadeTimerState.Exit;
             }
             break;
         case FadeTimerState.Exit:
             if(m_channelVolume > 0) {
                 // Decrease the volume
                 if(m_channelVolume < -m_exitFadeDelta) {
                     // Will fmod cap it at 0 if a lower value is set, or does
                     // this need to be done to get it to set it when the value
                     // would be < 0?
                     Volume = 0;
                 } else {
                     Volume = m_channelVolume + m_exitFadeDelta;
                 }
             } else {
                 // Done with the exit fade so the fade
                 // timer is no longer needed.
                 m_fadeTimerState = FadeTimerState.Inactive;
             }
             break;
     }
 }
示例#6
0
 public void ImmediateFade(int durationInSeconds)
 {
     if(durationInSeconds != 0) {
         m_exitFadeDelta = -1.0f / (durationInSeconds * ((float)1000 / FADE_TIMER_INTERVAL));
         m_exitFadeThreshold = Position + FADE_TIMER_INTERVAL;
         m_fadeTimerState = FadeTimerState.Threshold;
         if(!m_fadeTimer.Enabled) m_fadeTimer.Enabled = true;
     }
 }
示例#7
0
 public void CancelFades()
 {
     m_fadeTimer.Enabled = false;
     m_fadeTimerState = FadeTimerState.Inactive;
     m_entryFadeDelta = 0;
     m_exitFadeDelta = 0;
     m_exitFadeThreshold = 0;
 }
示例#8
0
        void fadeTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            switch (m_fadeTimerState)
            {
            case FadeTimerState.Inactive:
                // It shouldn't be running, so kill it
                m_fadeTimer.Enabled = false;
                break;

            case FadeTimerState.Entry:
                if (m_channelVolume < 1)
                {
                    // Increase the volume
                    if (1.0f - m_channelVolume < m_entryFadeDelta)
                    {
                        // Will fmod cap it at 1 if a higher value is set, or does
                        // this need to be done to get it to set it when the value
                        // would be > 1?
                        Volume = 1;
                    }
                    else
                    {
                        Volume = m_channelVolume + m_entryFadeDelta;
                    }
                }
                else if (m_exitFadeDelta != 0)
                {
                    // Done with the entry fade, but there's an exit fade that needs
                    // to be watched for.
                    m_fadeTimerState = FadeTimerState.Threshold;
                }
                else
                {
                    // Done with the entry fade and there is no exit fade, so the fade
                    // timer is no longer needed.
                    m_fadeTimerState = FadeTimerState.Inactive;
                }
                break;

            case FadeTimerState.Threshold:
                // Waiting to pass the exit fade threshold
                if (m_exitFadeThreshold != 0 && Position >= m_exitFadeThreshold)
                {
                    // Start the exit fade
                    m_fadeTimerState = FadeTimerState.Exit;
                }
                break;

            case FadeTimerState.Exit:
                if (m_channelVolume > 0)
                {
                    // Decrease the volume
                    if (m_channelVolume < -m_exitFadeDelta)
                    {
                        // Will fmod cap it at 0 if a lower value is set, or does
                        // this need to be done to get it to set it when the value
                        // would be < 0?
                        Volume = 0;
                    }
                    else
                    {
                        Volume = m_channelVolume + m_exitFadeDelta;
                    }
                }
                else
                {
                    // Done with the exit fade so the fade
                    // timer is no longer needed.
                    m_fadeTimerState = FadeTimerState.Inactive;
                }
                break;
            }
        }
示例#9
0
        private void fadeTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            switch (this.m_fadeTimerState)
            {
                case FadeTimerState.Inactive:
                    this.m_fadeTimer.Enabled = false;
                    break;

                case FadeTimerState.Entry:
                    if (this.m_channelVolume >= 1f)
                    {
                        if (this.m_exitFadeDelta != 0f)
                        {
                            this.m_fadeTimerState = FadeTimerState.Threshold;
                        }
                        else
                        {
                            this.m_fadeTimerState = FadeTimerState.Inactive;
                        }
                        break;
                    }
                    if ((1f - this.m_channelVolume) >= this.m_entryFadeDelta)
                    {
                        this.Volume = this.m_channelVolume + this.m_entryFadeDelta;
                        break;
                    }
                    this.Volume = 1f;
                    break;

                case FadeTimerState.Threshold:
                    if ((this.m_exitFadeThreshold != 0f) && (this.Position >= this.m_exitFadeThreshold))
                    {
                        this.m_fadeTimerState = FadeTimerState.Exit;
                    }
                    break;

                case FadeTimerState.Exit:
                    if (this.m_channelVolume <= 0f)
                    {
                        this.m_fadeTimerState = FadeTimerState.Inactive;
                        break;
                    }
                    if (this.m_channelVolume >= -this.m_exitFadeDelta)
                    {
                        this.Volume = this.m_channelVolume + this.m_exitFadeDelta;
                        break;
                    }
                    this.Volume = 0f;
                    break;
            }
        }
示例#10
0
 public void ImmediateFade(int durationInSeconds)
 {
     if (durationInSeconds != 0)
     {
         this.m_exitFadeDelta = -1f / (durationInSeconds * 10f);
         this.m_exitFadeThreshold = this.Position + 100;
         this.m_fadeTimerState = FadeTimerState.Threshold;
         if (!this.m_fadeTimer.Enabled)
         {
             this.m_fadeTimer.Enabled = true;
         }
     }
 }