本文整理汇总了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;
}
示例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;
}
示例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;
}