Xeno-rat
Loading...
Searching...
No Matches
NAudio.Midi.MidiEventCollection Class Reference

A helper class to manage collection of MIDI events It has the ability to organise them in tracks. More...

Inheritance diagram for NAudio.Midi.MidiEventCollection:
Collaboration diagram for NAudio.Midi.MidiEventCollection:

Public Member Functions

 MidiEventCollection (int midiFileType, int deltaTicksPerQuarterNote)
 Creates a new Midi Event collection.
 
IList< MidiEventGetTrackEvents (int trackNumber)
 Retrieves the MIDI events for the specified track number.
 
IList< MidiEventAddTrack ()
 Adds a list of MIDI events to the track and returns the combined list of events.
 
IList< MidiEventAddTrack (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.
 

Properties

int Tracks [get]
 The number of tracks.
 
long StartAbsoluteTime [get, set]
 The absolute time that should be considered as time zero Not directly used here, but useful for timeshifting applications.
 
int DeltaTicksPerQuarterNote [get]
 The number of ticks per quarter note.
 
IList< MidiEventthis[int trackNumber] [get]
 Gets events on a specific track.
 
int MidiFileType [get, set]
 The MIDI file type.
 

Private Member Functions

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.
 

Private Attributes

int midiFileType
 
readonly List< IList< MidiEvent > > trackEvents
 

Detailed Description

A helper class to manage collection of MIDI events It has the ability to organise them in tracks.

Constructor & Destructor Documentation

◆ MidiEventCollection()

NAudio.Midi.MidiEventCollection.MidiEventCollection ( int midiFileType,
int deltaTicksPerQuarterNote )
inline

Creates a new Midi Event collection.

Parameters
midiFileTypeInitial file type
deltaTicksPerQuarterNoteDelta Ticks Per Quarter Note

Member Function Documentation

◆ AddEvent()

void NAudio.Midi.MidiEventCollection.AddEvent ( MidiEvent midiEvent,
int originalTrack )
inline

Adds a MIDI event to the specified track.

Parameters
midiEventThe MIDI event to be added.
originalTrackThe original track number of the MIDI event.
Exceptions
InvalidOperationExceptionThrown 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
initialEventsThe 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddTrack() [2/2]

IList< MidiEvent > NAudio.Midi.MidiEventCollection.AddTrack ( IList< MidiEvent > initialEvents)
inline

Adds a new track.

Parameters
initialEventsInitial 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.

Here is the caller graph for this function:

◆ 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
countThe 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.

Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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
trackNumberThe 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:

  1. Sorts each track using the MergeSort algorithm with the provided comparer.
  2. Removes all but one End track event at the very end of each track.
  3. Removes empty tracks and adds missing End track events if necessary.

This method modifies the original MIDI data in place.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveTrack()

void NAudio.Midi.MidiEventCollection.RemoveTrack ( int track)
inline

Removes the track at the specified index from the track events collection.

Parameters
trackThe index of the track to be removed.

This method removes the track at the specified index from the track events collection.

Here is the caller graph for this function:

Member Data Documentation

◆ midiFileType

int NAudio.Midi.MidiEventCollection.midiFileType
private

◆ trackEvents

readonly List<IList<MidiEvent> > NAudio.Midi.MidiEventCollection.trackEvents
private

Property Documentation

◆ DeltaTicksPerQuarterNote

int NAudio.Midi.MidiEventCollection.DeltaTicksPerQuarterNote
get

The number of ticks per quarter note.

◆ MidiFileType

int NAudio.Midi.MidiEventCollection.MidiFileType
getset

The MIDI file type.

◆ 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
trackNumberTrack number
Returns
The list of events

◆ Tracks

int NAudio.Midi.MidiEventCollection.Tracks
get

The number of tracks.


The documentation for this class was generated from the following file: