Beispiel #1
0
        public float Process()
        {
            switch (this.state)
            {
            case EnvelopeGenerator.EnvelopeState.Attack:
                this.output = this.attackBase + this.output * this.attackCoef;
                if (this.output >= 1f)
                {
                    this.output = 1f;
                    this.state  = EnvelopeGenerator.EnvelopeState.Decay;
                }
                break;

            case EnvelopeGenerator.EnvelopeState.Decay:
                this.output = this.decayBase + this.output * this.decayCoef;
                if (this.output <= this.sustainLevel)
                {
                    this.output = this.sustainLevel;
                    this.state  = EnvelopeGenerator.EnvelopeState.Sustain;
                }
                break;

            case EnvelopeGenerator.EnvelopeState.Release:
                this.output = this.releaseBase + this.output * this.releaseCoef;
                if ((double)this.output <= 0.0)
                {
                    this.output = 0f;
                    this.state  = EnvelopeGenerator.EnvelopeState.Idle;
                }
                break;
            }
            return(this.output);
        }
Beispiel #2
0
 public void Gate(bool gate)
 {
     if (gate)
     {
         this.state = EnvelopeGenerator.EnvelopeState.Attack;
         return;
     }
     if (this.state != EnvelopeGenerator.EnvelopeState.Idle)
     {
         this.state = EnvelopeGenerator.EnvelopeState.Release;
     }
 }
Beispiel #3
0
 public void Reset()
 {
     this.state  = EnvelopeGenerator.EnvelopeState.Idle;
     this.output = 0f;
 }