private void ParseChannelMessage() { if (trackIndex >= trackData.Length) { throw new MidiFileException("End of track unexpectedly reached."); } cmBuilder.Command = ChannelMessage.UnpackCommand(status); cmBuilder.MidiChannel = ChannelMessage.UnpackMidiChannel(status); cmBuilder.Data1 = trackData[trackIndex]; cmBuilder.MidiTrack = trackNumber; trackIndex++; if (ChannelMessage.DataBytesPerType(cmBuilder.Command) == 2) { if (trackIndex >= trackData.Length) { throw new MidiFileException("End of track unexpectedly reached."); } cmBuilder.Data2 = trackData[trackIndex]; trackIndex++; } cmBuilder.Build(); newTrack.Insert(ticks, cmBuilder.Result); runningStatus = status; }