当前位置: 首页>>代码示例>>C#>>正文


C# FastList.IndexOf方法代码示例

本文整理汇总了C#中FastList.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# FastList.IndexOf方法的具体用法?C# FastList.IndexOf怎么用?C# FastList.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FastList的用法示例。


在下文中一共展示了FastList.IndexOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TrackVoiceStats

 private static int TrackVoiceStats(MidiEvent midiEvent, FastList<byte> instList, FastList<byte> drumList, FastList<byte> channelList, int noteOnCount)
 {
     if (midiEvent.Command == MidiEventTypeEnum.NoteOn)
     {
         var chan = midiEvent.Channel;
         if (channelList.IndexOf((byte)chan) == -1)
             channelList.Add((byte)chan);
         noteOnCount++;
     }
     else if (midiEvent.Command == MidiEventTypeEnum.ProgramChange)
     {
         var chan = midiEvent.Channel;
         var prog = midiEvent.Data1;
         if (chan == MidiHelper.DrumChannel)
         {
             if (drumList.IndexOf((byte)prog) == -1)
                 drumList.Add((byte)prog);
         }
         else
         {
             if (instList.IndexOf((byte)prog) == -1)
                 instList.Add((byte)prog);
         }
     }
     return noteOnCount;
 }
开发者ID:eriser,项目名称:alphaSynth,代码行数:26,代码来源:MidiFile.cs

示例2: MergeTracks

        public MidiTrack MergeTracks()
        {
            var eventCount = 0;
            var notesPlayed = 0;
            var programsUsed = new FastList<byte>();
            var drumProgramsUsed = new FastList<byte>();
            var channelsUsed = new FastList<byte>();
            for (int x = 0; x < Tracks.Length; x++)
            {
                eventCount += Tracks[x].MidiEvents.Length;
                notesPlayed += Tracks[x].NoteOnCount;

                for (int i = 0; i < Tracks[x].Instruments.Length; i++)
                {
                    var p = Tracks[x].Instruments[i];
                    if (programsUsed.IndexOf(p) == -1)
                        programsUsed.Add(p);
                }
                for (int i = 0; i < Tracks[x].DrumInstruments.Length; i++)
                {
                    var p = Tracks[x].DrumInstruments[i];
                    if (drumProgramsUsed.IndexOf(p) == -1)
                        drumProgramsUsed.Add(p);
                }

                for (int i = 0; i < Tracks[x].ActiveChannels.Length; i++)
                {
                    var p = Tracks[x].ActiveChannels[i];
                    if (channelsUsed.IndexOf(p) == -1)
                        channelsUsed.Add(p);
                }
            }

            var track = new MidiTrack(programsUsed.ToArray(),
                                                drumProgramsUsed.ToArray(),
                                                channelsUsed.ToArray(),
                                                new MidiEvent[eventCount]);
            track.NoteOnCount = notesPlayed;
            return track;
        }
开发者ID:eriser,项目名称:alphaSynth,代码行数:40,代码来源:MidiFile.cs

示例3: ReadTrack

        private MidiTrack ReadTrack(IReadable input)
        {
            var instList = new FastList<Byte>();
            var drumList = new FastList<Byte>();
            var channelList = new FastList<Byte>();
            var eventList = new FastList<MidiEvent>();
            var noteOnCount = 0;
            var totalTime = 0;
            while (input.Read8BitChars(4) != "MTrk")
            {
                var length = input.ReadInt32BE();
                while (length > 0)
                {
                    length--;
                    input.ReadByte();
                }
            }

            var endPosition = input.ReadInt32BE() + input.Position;
            var prevStatus = 0;
            while (input.Position < endPosition)
            {
                var delta = ReadVariableLength(input);
                totalTime += delta;
                var status = input.ReadByte();
                if (status >= 0x80 && status <= 0xEF)
                {//voice message
                    prevStatus = status;
                    eventList.Add(ReadVoiceMessage(input, delta, (byte)status, (byte)input.ReadByte()));
                    noteOnCount = TrackVoiceStats(eventList[eventList.Count - 1], instList, drumList, channelList, noteOnCount);
                }
                else if (status >= 0xF0 && status <= 0xF7)
                {//system common message
                    prevStatus = 0;
                    eventList.Add(ReadSystemCommonMessage(input, delta, (byte)status));
                }
                else if (status >= 0xF8 && status <= 0xFF)
                {//realtime message
                    eventList.Add(ReadRealTimeMessage(input, delta, (byte)status));
                }
                else
                {//data bytes
                    if (prevStatus == 0)
                    {//if no running status continue to next status byte
                        while ((status & 0x80) != 0x80)
                        {
                            status = input.ReadByte();
                        }
                        if (status >= 0x80 && status <= 0xEF)
                        {//voice message
                            prevStatus = status;
                            eventList.Add(ReadVoiceMessage(input, delta, (byte)status, (byte)input.ReadByte()));
                            noteOnCount = TrackVoiceStats(eventList[eventList.Count - 1], instList, drumList, channelList, noteOnCount);
                        }
                        else if (status >= 0xF0 && status <= 0xF7)
                        {//system common message
                            eventList.Add(ReadSystemCommonMessage(input, delta, (byte)status));
                        }
                        else if (status >= 0xF8 && status <= 0xFF)
                        {//realtime message
                            eventList.Add(ReadRealTimeMessage(input, delta, (byte)status));
                        }
                    }
                    else
                    {//otherwise apply running status
                        eventList.Add(ReadVoiceMessage(input, delta, (byte)prevStatus, (byte)status));
                        noteOnCount = TrackVoiceStats(eventList[eventList.Count - 1], instList, drumList, channelList, noteOnCount);
                    }
                }
            }

            if (input.Position != endPosition)
                throw new Exception("The track length was invalid for the current MTrk chunk.");
            if (channelList.IndexOf(MidiHelper.DrumChannel) != -1)
            {
                if (drumList.IndexOf(0) == -1)
                    drumList.Add(0);
            }
            else
            {
                if (instList.IndexOf(0) == -1)
                    instList.Add(0);
            }
            var track = new MidiTrack(instList.ToArray(),
                drumList.ToArray(),
                channelList.ToArray(),
                eventList.ToArray());
            track.NoteOnCount = noteOnCount;
            track.EndTime = totalTime;
            return track;
        }
开发者ID:eriser,项目名称:alphaSynth,代码行数:91,代码来源:MidiFile.cs


注:本文中的FastList.IndexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。