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; }
private void Write(ChannelMessage message) { if (runningStatus != message.Status) { trackData.Add((byte)message.Status); runningStatus = message.Status; } trackData.Add((byte)message.Data1); if (ChannelMessage.DataBytesPerType(message.Command) == 2) { trackData.Add((byte)message.Data2); } }