/// <summary>Inserts a new MIDI channel message/event into this file at the specified index.</summary> /// <param name="index">The index in this file's list at which the event should be inserted.</param> /// <param name="deltaTime">The amount of time (in ticks) between the previous event in the track and this one.</param> /// <param name="status">The status byte of the event, or -1 for running status.</param> /// <param name="data1">The first data byte of the event.</param> /// <param name="data2">The second data byte of the event (if applicable).</param> /// <returns>The new MidiChannelEvent object that is inserted.</returns> public MidiChannelEvent InsertChannelEvent(int index, int deltaTime, int status, int data1, int data2) { int offset = this.Items[index].Offset, n = (status < 0) ? this.GetRunningStatus(offset) : status; MidiMessageType messageType = (MidiMessageType)Midi.GetHighNibble(n); n = MidiChannelEvent.SizeItem(0, (status < 0), messageType); this.Resize(n, offset, index); MidiChannelEvent channelEvent = this.CreateChannelEvent(offset, deltaTime, status, data1, data2); this.Items.Insert(index, channelEvent); this.SetTotalTime(index); return(channelEvent); }
/// <summary>Adds a new MIDI channel message/event to the end of this file.</summary> /// <param name="deltaTime">The amount of time (in ticks) between the previous event in the track and this one.</param> /// <param name="status">The status byte of the event, or -1 for running status.</param> /// <param name="data1">The first data byte of the event.</param> /// <param name="data2">The second data byte of the event (if applicable).</param> /// <returns>The new MidiChannelEvent object that is added.</returns> public MidiChannelEvent AddChannelEvent(int deltaTime, int status, int data1, int data2) { int offset = this.Bytes.Length, n = (status < 0) ? this.GetRunningStatus(offset) : status; MidiMessageType messageType = (MidiMessageType)Midi.GetHighNibble(n); n = MidiChannelEvent.SizeItem(0, (status < 0), messageType); this.Resize(n, offset, this.ItemCount); MidiChannelEvent channelEvent = this.CreateChannelEvent(offset, deltaTime, status, data1, data2); this.Items.Add(channelEvent); this.SetTotalTime(this.ItemCount - 1); return(channelEvent); }