Esempio n. 1
0
 private void method_3(Stream midiStream)
 {
     BinaryReader midiFile = new BinaryReader(midiStream);
     ByteFiddler.smethod_3("MIDI", midiFile, "MThd");
     ByteFiddler.RotateLeft(midiFile.ReadUInt32());
     ByteFiddler.RotateRight(midiFile.ReadUInt16());
     int num = (int)ByteFiddler.RotateRight(midiFile.ReadUInt16());
     this.method_1((int)ByteFiddler.RotateRight(midiFile.ReadUInt16()));
     this.midiLineList.Clear();
     for (int i = 0; i < num; i++)
     {
         MIDILine midiLine = new MIDILine(this.method_0());
         this.midiLineList.Add(midiLine);
         List<AbstractNoteClass> list = new List<AbstractNoteClass>();
         ByteFiddler.smethod_3("MIDI", midiFile, "MTrk");
         uint num2 = ByteFiddler.RotateLeft(midiFile.ReadUInt32());
         long position = midiFile.BaseStream.Position;
         int num3 = 0;
         byte b = 0;
         while (midiFile.BaseStream.Position < position + (long)((ulong)num2))
         {
             int num4 = (int)this.method_4(midiFile);
             AbstractNoteClass midiNote = null;
             num3 += num4;
             byte b2 = midiFile.ReadByte();
             if (b2 != 255)
             {
                 byte int_;
                 if ((b2 & 128) == 128)
                 {
                     int_ = midiFile.ReadByte();
                     b = b2;
                 }
                 else
                 {
                     int_ = b2;
                     b2 = b;
                 }
                 byte b3 = (byte)(b2 >> 4);
                 switch (b3)
                 {
                 case 8:
                     midiNote = new MIDINote(num3, (int)int_, midiFile.ReadByte(), false);
                     goto IL_298;
                 case 9:
                     midiNote = new MIDINote(num3, (int)int_, midiFile.ReadByte(), true);
                     goto IL_298;
                 case 11:
                 case 12:
                 case 14:
                     goto IL_298;
                 }
                 throw new NotImplementedException(string.Format("Unhandled MIDI command: {0} at position {1}", b3.ToString("X"), midiFile.BaseStream.Position));
             }
             byte b4 = midiFile.ReadByte();
             long num5 = this.method_4(midiFile);
             byte[] array = midiFile.ReadBytes((int)num5);
             byte b5 = b4;
             if (b5 <= 47)
             {
                 switch (b5)
                 {
                 case 1:
                     midiNote = new zzNote1(num3, zzNote1.Enum37.const_0, Encoding.ASCII.GetString(array));
                     break;
                 case 2:
                     break;
                 case 3:
                 {
                     string text = Encoding.ASCII.GetString(array).ToUpper();
                     if (!string.IsNullOrEmpty(text))
                     {
                         midiLine.method_3(text);
                     }
                     break;
                 }
                 default:
                     if (b5 != 47)
                     {
                     }
                     break;
                 }
             }
             else if (b5 != 81)
             {
                 if (b5 == 88)
                 {
                     if (num5 != 4L)
                     {
                         Class355.interface15_0.imethod_1(string.Format("Expected time signature event to have data length of 4, but found instead {0}", num5));
                     }
                     midiNote = new zzNote338(num3, (int)array[0], (int)array[1], (int)array[2], (int)array[3]);
                 }
             }
             else
             {
                 if (num5 != 3L)
                 {
                     Class355.interface15_0.imethod_1(string.Format("Expected tempo event to have data length of 3, but found instead {0}", num5));
                 }
                 int num6 = (int)array[0] << 16;
                 num6 |= (int)array[1] << 8;
                 num6 |= (int)array[2];
                 midiNote = new BpmNote1(num3, num6);
             }
             IL_298:
             if (midiNote != null)
             {
                 list.Add(midiNote);
             }
         }
         list.Sort(new Comparison<AbstractNoteClass>(AbstractNoteClass.smethod_0));
         midiLine.method_1(list);
         midiFile.BaseStream.Seek(position + (long)((ulong)num2), SeekOrigin.Begin);
     }
 }
Esempio n. 2
0
 private void getNotes(MIDILine midiLine, int difficulty)
 {
     bool[] array = new bool[midiLine.method_0().Count];
     List<AbstractNoteClass> list = midiLine.method_0();
     for (int i = 0; i < list.Count; i++)
     {
         if (!array[i])
         {
             int num = Convert.ToInt32((double)list[i].method_0() * this.resolution);
             if (list[i] is MIDINote)
             {
                 MIDINote midiNote = (MIDINote)list[i];
                 if (midiNote.method_5())
                 {
                     int j = -1;
                     int num2 = i + 1;
                     while (j < 0)
                     {
                         if (num2 == midiLine.method_0().Count)
                         {
                             break;
                         }
                         if (list[num2] is MIDINote && ((MIDINote)list[num2]).method_4() == midiNote.method_4())
                         {
                             if (((MIDINote)list[num2]).method_5())
                             {
                                 j = Convert.ToInt32((double)list[num2].method_0() * this.resolution);
                                 array[num2] = true;
                             }
                             else
                             {
                                 j = Convert.ToInt32((double)list[num2].method_0() * this.resolution);
                             }
                         }
                         num2++;
                     }
                     int num3 = Convert.ToInt32(j - num);
                     if (num3 <= 160)
                     {
                         num3 = 0;
                     }
                     this.method_3(difficulty, num, midiNote, num3);
                 }
             }
             else if (list[i] is zzNote1)
             {
                 zzNote1 class2 = (zzNote1)list[i];
                 List<string> list2 = this.method_5(difficulty - 4);
                 string text = class2.method_1();
                 if (text.StartsWith("["))
                 {
                     text = text.Substring(1, text.Length - 2);
                 }
                 if (list2.Contains(text) || text.Contains("section "))
                 {
                     this.method_4(difficulty, num, text);
                 }
             }
         }
     }
 }
Esempio n. 3
0
 private void method_1(MIDILine class353_0)
 {
     this.songTitle = class353_0.method_2();
     foreach (AbstractNoteClass current in class353_0.method_0())
     {
         int num = Convert.ToInt32((double)current.method_0() * this.resolution);
         if (current is zzNote1)
         {
             zzNote1 @class = (zzNote1)current;
             if (!this.isEvents && @class.method_2() == zzNote1.Enum37.const_0)
             {
                 this.method_4(4, num, "section " + @class.method_1());
             }
         }
         else if (current is BpmNote1)
         {
             int num2 = ((BpmNote1)current).method_1();
             this.bpmInterpreter.bpmList.Add(num, Convert.ToInt32(Math.Floor(60000000.0 / (double)num2 * 1000.0)));
         }
         else if (current is zzNote338)
         {
             this.bpmInterpreter.TSList.Add(num, ((zzNote338)current).method_1());
         }
     }
 }
Esempio n. 4
0
        private void method_3(Stream midiStream)
        {
            BinaryReader midiFile = new BinaryReader(midiStream);

            ByteFiddler.smethod_3("MIDI", midiFile, "MThd");
            ByteFiddler.RotateLeft(midiFile.ReadUInt32());
            ByteFiddler.RotateRight(midiFile.ReadUInt16());
            int num = (int)ByteFiddler.RotateRight(midiFile.ReadUInt16());

            this.method_1((int)ByteFiddler.RotateRight(midiFile.ReadUInt16()));
            this.midiLineList.Clear();
            for (int i = 0; i < num; i++)
            {
                MIDILine midiLine = new MIDILine(this.method_0());
                this.midiLineList.Add(midiLine);
                List <AbstractNoteClass> list = new List <AbstractNoteClass>();
                ByteFiddler.smethod_3("MIDI", midiFile, "MTrk");
                uint num2     = ByteFiddler.RotateLeft(midiFile.ReadUInt32());
                long position = midiFile.BaseStream.Position;
                int  num3     = 0;
                byte b        = 0;
                while (midiFile.BaseStream.Position < position + (long)((ulong)num2))
                {
                    int num4 = (int)this.method_4(midiFile);
                    AbstractNoteClass midiNote = null;
                    num3 += num4;
                    byte b2 = midiFile.ReadByte();
                    if (b2 != 255)
                    {
                        byte int_;
                        if ((b2 & 128) == 128)
                        {
                            int_ = midiFile.ReadByte();
                            b    = b2;
                        }
                        else
                        {
                            int_ = b2;
                            b2   = b;
                        }
                        byte b3 = (byte)(b2 >> 4);
                        switch (b3)
                        {
                        case 8:
                            midiNote = new MIDINote(num3, (int)int_, midiFile.ReadByte(), false);
                            goto IL_298;

                        case 9:
                            midiNote = new MIDINote(num3, (int)int_, midiFile.ReadByte(), true);
                            goto IL_298;

                        case 11:
                        case 12:
                        case 14:
                            goto IL_298;
                        }
                        throw new NotImplementedException(string.Format("Unhandled MIDI command: {0} at position {1}", b3.ToString("X"), midiFile.BaseStream.Position));
                    }
                    byte   b4    = midiFile.ReadByte();
                    long   num5  = this.method_4(midiFile);
                    byte[] array = midiFile.ReadBytes((int)num5);
                    byte   b5    = b4;
                    if (b5 <= 47)
                    {
                        switch (b5)
                        {
                        case 1:
                            midiNote = new zzNote1(num3, zzNote1.Enum37.const_0, Encoding.ASCII.GetString(array));
                            break;

                        case 2:
                            break;

                        case 3:
                        {
                            string text = Encoding.ASCII.GetString(array).ToUpper();
                            if (!string.IsNullOrEmpty(text))
                            {
                                midiLine.method_3(text);
                            }
                            break;
                        }

                        default:
                            if (b5 != 47)
                            {
                            }
                            break;
                        }
                    }
                    else if (b5 != 81)
                    {
                        if (b5 == 88)
                        {
                            if (num5 != 4L)
                            {
                                Class355.interface15_0.imethod_1(string.Format("Expected time signature event to have data length of 4, but found instead {0}", num5));
                            }
                            midiNote = new zzNote338(num3, (int)array[0], (int)array[1], (int)array[2], (int)array[3]);
                        }
                    }
                    else
                    {
                        if (num5 != 3L)
                        {
                            Class355.interface15_0.imethod_1(string.Format("Expected tempo event to have data length of 3, but found instead {0}", num5));
                        }
                        int num6 = (int)array[0] << 16;
                        num6    |= (int)array[1] << 8;
                        num6    |= (int)array[2];
                        midiNote = new BpmNote1(num3, num6);
                    }
IL_298:
                    if (midiNote != null)
                    {
                        list.Add(midiNote);
                    }
                }
                list.Sort(new Comparison <AbstractNoteClass>(AbstractNoteClass.smethod_0));
                midiLine.method_1(list);
                midiFile.BaseStream.Seek(position + (long)((ulong)num2), SeekOrigin.Begin);
            }
        }