NScumm.Core.Audio.SoftSynth.AdlibMidiDriver.AdlibPlayNote C# (CSharp) Method

AdlibPlayNote() private method

private AdlibPlayNote ( int channel, int note ) : void
channel int
note int
return void
        void AdlibPlayNote(int channel, int note)
        {
            byte old, oct, notex;
            int note2;
            int i;

            note2 = (note >> 7) - 4;
            note2 = (note2 < 128) ? note2 : 0;

            oct = (byte)(note2 / 12);
            if (oct > 7)
                oct = 7 << 2;
            else
                oct <<= 2;
            notex = (byte)(note2 % 12 + 3);

            old = AdlibGetRegValue((byte)(channel + 0xB0));
            if ((old & 0x20) != 0)
            {
                old &= 0xdf;
                if (oct > old)
                {
                    if (notex < 6)
                    {
                        notex += 12;
                        oct -= 4;
                    }
                }
                else if (oct < old)
                {
                    if (notex > 11)
                    {
                        notex -= 12;
                        oct += 4;
                    }
                }
            }

            i = (notex << 3) + ((note >> 4) & 0x7);
            AdlibWrite((byte)(channel + 0xA0), noteFrequencies[i]);
            AdlibWrite((byte)(channel + 0xB0), (byte)(oct | 0x20));
        }