NScumm.Core.Audio.SoftSynth.EnvelopeGenerator.WriteCONTROL_REG C# (CSharp) Method

WriteCONTROL_REG() public method

public WriteCONTROL_REG ( int control ) : void
control int
return void
        public void WriteCONTROL_REG(int control)
        {
            var gate_next = control & 0x01;

            // The rate counter is never reset, thus there will be a delay before the
            // envelope counter starts counting up (attack) or down (release).

            // Gate bit on: Start attack, decay, sustain.
            if (gate==0 && gate_next!=0)
            {
                state = State.ATTACK;
                rate_period = rate_counter_period[attack];

                // Switching to attack state unlocks the zero freeze.
                hold_zero = false;
            }
            // Gate bit off: Start release.
            else if (gate!=0 && gate_next==0)
            {
                state = State.RELEASE;
                rate_period = rate_counter_period[release];
            }

            gate = gate_next;
        }