Beispiel #1
0
        public override MidiEvent Clone()
        {
            SysexEvent expr_05 = new SysexEvent();

            byte[] expr_0C = this.data;
            expr_05.data = (byte[])((expr_0C != null) ? expr_0C.Clone() : null);
            return(expr_05);
        }
Beispiel #2
0
        public static SysexEvent ReadSysexEvent(BinaryReader br)
        {
            SysexEvent  sysexEvent = new SysexEvent();
            List <byte> list       = new List <byte>();
            bool        flag       = true;

            while (flag)
            {
                byte b = br.ReadByte();
                if (b == 247)
                {
                    flag = false;
                }
                else
                {
                    list.Add(b);
                }
            }
            sysexEvent.data = list.ToArray();
            return(sysexEvent);
        }
Beispiel #3
0
        public static MidiEvent ReadNextEvent(BinaryReader br, MidiEvent previous)
        {
            int             num  = MidiEvent.ReadVarInt(br);
            int             num2 = 1;
            byte            b    = br.ReadByte();
            MidiCommandCode midiCommandCode;

            if ((b & 128) == 0)
            {
                midiCommandCode = previous.CommandCode;
                num2            = previous.Channel;
                Stream expr_2D  = br.BaseStream;
                long   position = expr_2D.Position;
                expr_2D.Position = position - 1L;
            }
            else if ((b & 240) == 240)
            {
                midiCommandCode = (MidiCommandCode)b;
            }
            else
            {
                midiCommandCode = (MidiCommandCode)(b & 240);
                num2            = (int)((b & 15) + 1);
            }
            MidiEvent midiEvent;

            if (midiCommandCode <= MidiCommandCode.ControlChange)
            {
                if (midiCommandCode <= MidiCommandCode.NoteOn)
                {
                    if (midiCommandCode != MidiCommandCode.NoteOff)
                    {
                        if (midiCommandCode != MidiCommandCode.NoteOn)
                        {
                            goto IL_154;
                        }
                        midiEvent = new NoteOnEvent(br);
                        goto IL_16A;
                    }
                }
                else if (midiCommandCode != MidiCommandCode.KeyAfterTouch)
                {
                    if (midiCommandCode != MidiCommandCode.ControlChange)
                    {
                        goto IL_154;
                    }
                    midiEvent = new ControlChangeEvent(br);
                    goto IL_16A;
                }
                midiEvent = new NoteEvent(br);
                goto IL_16A;
            }
            if (midiCommandCode <= MidiCommandCode.ChannelAfterTouch)
            {
                if (midiCommandCode == MidiCommandCode.PatchChange)
                {
                    midiEvent = new PatchChangeEvent(br);
                    goto IL_16A;
                }
                if (midiCommandCode == MidiCommandCode.ChannelAfterTouch)
                {
                    midiEvent = new ChannelAfterTouchEvent(br);
                    goto IL_16A;
                }
            }
            else
            {
                if (midiCommandCode == MidiCommandCode.PitchWheelChange)
                {
                    midiEvent = new PitchWheelChangeEvent(br);
                    goto IL_16A;
                }
                if (midiCommandCode == MidiCommandCode.Sysex)
                {
                    midiEvent = SysexEvent.ReadSysexEvent(br);
                    goto IL_16A;
                }
                switch (midiCommandCode)
                {
                case MidiCommandCode.TimingClock:
                case MidiCommandCode.StartSequence:
                case MidiCommandCode.ContinueSequence:
                case MidiCommandCode.StopSequence:
                    midiEvent = new MidiEvent();
                    goto IL_16A;

                case MidiCommandCode.MetaEvent:
                    midiEvent = MetaEvent.ReadMetaEvent(br);
                    goto IL_16A;
                }
            }
IL_154:
            throw new FormatException(string.Format("Unsupported MIDI Command Code {0:X2}", (byte)midiCommandCode));
IL_16A:
            midiEvent.channel     = num2;
            midiEvent.deltaTime   = num;
            midiEvent.commandCode = midiCommandCode;
            return(midiEvent);
        }