NScumm.Core.Audio.PCSpeakerDriver.MidiChannelPcSpk.NoteOn C# (CSharp) Method

NoteOn() public method

public NoteOn ( byte note, byte velocity ) : void
note byte
velocity byte
return void
            public override void NoteOn(byte note, byte velocity)
            {
                if (!_allocated)
                    return;

                _out.note = note;
                _out.sustainNoteOff = 0;
                _out.length = _instrument[0];

                if (_instrument[4] < PCSpeakerDriver._outInstrumentData.Length)
                    _out.instrument = PCSpeakerDriver._outInstrumentData[_instrument[4]];
                else
                    _out.instrument = null;

                _out.unkA = 0;
                _out.unkB = _instrument[1];
                _out.unkC = _instrument[2];
                _out.unkE = 0;
                _out.unk60 = 0;
                _out.active = 1;

                // In case we get a note on event on the last active channel, we reset the
                // last active channel, thus we assure the frequency is correctly set, even
                // when the same note was sent.
                if (_owner._lastActiveChannel == this)
                {
                    _owner._lastActiveChannel = null;
                    _owner._lastActiveOut = 0;
                }
                _owner.UpdateNote();

                _out.unkC += PCSpeakerDriver.GetEffectModifier((ushort)(_instrument[3] + ((velocity & 0xFE) << 4)));
                if (_out.unkC > 63)
                    _out.unkC = 63;

                if ((_instrument[5] & 0x80) != 0)
                    _owner.SetupEffects(this, _out.effectEnvelopeA, _out.effectDefA, _instrument[5], _instrument, 6);

                if ((_instrument[14] & 0x80) != 0)
                    _owner.SetupEffects(this, _out.effectEnvelopeB, _out.effectDefB, _instrument[14], _instrument, 15);
            }