A helper class to manage collection of MIDI events It has the ability to organise them in tracks.
More...
|
| MidiEventCollection (int midiFileType, int deltaTicksPerQuarterNote) |
| Creates a new Midi Event collection.
|
|
IList< MidiEvent > | GetTrackEvents (int trackNumber) |
| Retrieves the MIDI events for the specified track number.
|
|
IList< MidiEvent > | AddTrack () |
| Adds a list of MIDI events to the track and returns the combined list of events.
|
|
IList< MidiEvent > | AddTrack (IList< MidiEvent > initialEvents) |
| Adds a new track.
|
|
void | RemoveTrack (int track) |
| Removes the track at the specified index from the track events collection.
|
|
void | Clear () |
| Clears all the track events from the list.
|
|
void | AddEvent (MidiEvent midiEvent, int originalTrack) |
| Adds a MIDI event to the specified track.
|
|
void | PrepareForExport () |
| Prepares the MIDI data for export by performing the following steps:
|
|
IEnumerator< IList< MidiEvent > > | GetEnumerator () |
| Returns an enumerator that iterates through the collection of track events.
|
|
|
void | EnsureTracks (int count) |
| Ensures that the number of tracks in the trackEvents list is at least count by adding empty lists if necessary.
|
|
void | ExplodeToManyTracks () |
| Explodes the events of the first track into multiple tracks and prepares for export.
|
|
void | FlattenToOneTrack () |
| Flattens the multiple tracks into a single track.
|
|
System.Collections.IEnumerator System.Collections.IEnumerable. | GetEnumerator () |
| Gets an enumerator for the lists of track events.
|
|
A helper class to manage collection of MIDI events It has the ability to organise them in tracks.
◆ MidiEventCollection()
NAudio.Midi.MidiEventCollection.MidiEventCollection |
( |
int | midiFileType, |
|
|
int | deltaTicksPerQuarterNote ) |
|
inline |
Creates a new Midi Event collection.
- Parameters
-
midiFileType | Initial file type |
deltaTicksPerQuarterNote | Delta Ticks Per Quarter Note |
◆ AddEvent()
void NAudio.Midi.MidiEventCollection.AddEvent |
( |
MidiEvent | midiEvent, |
|
|
int | originalTrack ) |
|
inline |
Adds a MIDI event to the specified track.
- Parameters
-
midiEvent | The MIDI event to be added. |
originalTrack | The original track number of the MIDI event. |
- Exceptions
-
InvalidOperationException | Thrown when the MIDI file type is not recognized. |
This method adds the specified MIDI event to the appropriate track based on the MIDI file type and original track number. If the MIDI file type is 0, the event is added to the first track. If the MIDI file type is not 0, the event is added to a channel track based on its command code, or to the original track if specified.
◆ AddTrack() [1/2]
IList< MidiEvent > NAudio.Midi.MidiEventCollection.AddTrack |
( |
| ) |
|
|
inline |
Adds a list of MIDI events to the track and returns the combined list of events.
- Parameters
-
initialEvents | The initial list of MIDI events to be added to the track. |
- Returns
- The combined list of MIDI events after adding the initial events to the track.
◆ AddTrack() [2/2]
IList< MidiEvent > NAudio.Midi.MidiEventCollection.AddTrack |
( |
IList< MidiEvent > | initialEvents | ) |
|
|
inline |
Adds a new track.
- Parameters
-
initialEvents | Initial events to add to the new track |
- Returns
- The new track event list
◆ Clear()
void NAudio.Midi.MidiEventCollection.Clear |
( |
| ) |
|
|
inline |
Clears all the track events from the list.
This method removes all the track events from the list, effectively clearing it.
◆ EnsureTracks()
void NAudio.Midi.MidiEventCollection.EnsureTracks |
( |
int | count | ) |
|
|
inlineprivate |
Ensures that the number of tracks in the trackEvents list is at least count by adding empty lists if necessary.
- Parameters
-
count | The minimum number of tracks to be ensured in the trackEvents list. |
This method iterates through the trackEvents list and adds empty lists until the count of tracks reaches the specified count . If the count of tracks in the trackEvents list is already greater than or equal to count , no action is taken.
◆ ExplodeToManyTracks()
void NAudio.Midi.MidiEventCollection.ExplodeToManyTracks |
( |
| ) |
|
|
inlineprivate |
Explodes the events of the first track into multiple tracks and prepares for export.
This method retrieves the events from the first track, clears the existing tracks, and adds each event to a separate track. After adding the events to the tracks, it prepares the tracks for export.
◆ FlattenToOneTrack()
void NAudio.Midi.MidiEventCollection.FlattenToOneTrack |
( |
| ) |
|
|
inlineprivate |
Flattens the multiple tracks into a single track.
This method iterates through each track in the trackEvents and adds all non-end track MIDI events to the first track. After flattening, it removes all tracks except the first one. If any events are added during the process, it prepares the flattened track for export.
◆ GetEnumerator() [1/2]
IEnumerator< IList< MidiEvent > > NAudio.Midi.MidiEventCollection.GetEnumerator |
( |
| ) |
|
|
inline |
Returns an enumerator that iterates through the collection of track events.
- Returns
- An enumerator that can be used to iterate through the collection of track events.
◆ GetEnumerator() [2/2]
System.Collections.IEnumerator System.Collections.IEnumerable. NAudio.Midi.MidiEventCollection.GetEnumerator |
( |
| ) |
|
|
inlineprivate |
Gets an enumerator for the lists of track events.
◆ GetTrackEvents()
IList< MidiEvent > NAudio.Midi.MidiEventCollection.GetTrackEvents |
( |
int | trackNumber | ) |
|
|
inline |
Retrieves the MIDI events for the specified track number.
- Parameters
-
trackNumber | The number of the track for which MIDI events are to be retrieved. |
- Returns
- The list of MIDI events associated with the specified track number.
◆ PrepareForExport()
void NAudio.Midi.MidiEventCollection.PrepareForExport |
( |
| ) |
|
|
inline |
Prepares the MIDI data for export by performing the following steps:
- Sorts each track using the MergeSort algorithm with the provided comparer.
- Removes all but one End track event at the very end of each track.
- Removes empty tracks and adds missing End track events if necessary.
This method modifies the original MIDI data in place.
◆ RemoveTrack()
void NAudio.Midi.MidiEventCollection.RemoveTrack |
( |
int | track | ) |
|
|
inline |
Removes the track at the specified index from the track events collection.
- Parameters
-
track | The index of the track to be removed. |
This method removes the track at the specified index from the track events collection.
◆ midiFileType
int NAudio.Midi.MidiEventCollection.midiFileType |
|
private |
◆ trackEvents
readonly List<IList<MidiEvent> > NAudio.Midi.MidiEventCollection.trackEvents |
|
private |
◆ DeltaTicksPerQuarterNote
int NAudio.Midi.MidiEventCollection.DeltaTicksPerQuarterNote |
|
get |
The number of ticks per quarter note.
◆ MidiFileType
int NAudio.Midi.MidiEventCollection.MidiFileType |
|
getset |
◆ StartAbsoluteTime
long NAudio.Midi.MidiEventCollection.StartAbsoluteTime |
|
getset |
The absolute time that should be considered as time zero Not directly used here, but useful for timeshifting applications.
◆ this[int trackNumber]
IList<MidiEvent> NAudio.Midi.MidiEventCollection.this[int trackNumber] |
|
get |
Gets events on a specific track.
- Parameters
-
- Returns
- The list of events
◆ Tracks
int NAudio.Midi.MidiEventCollection.Tracks |
|
get |
The documentation for this class was generated from the following file:
- /Users/sumansaurabh/Documents/my-startup/xeno-rat/Plugins/LiveMicrophone/lib/NAudio.Midi/Midi/MidiEventCollection.cs