Table of Contents

Class MidiEventCollection

Namespace
NAudio.Midi
Assembly
NAudio.Midi.dll

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

public class MidiEventCollection : IEnumerable<IList<MidiEvent>>, IEnumerable
Inheritance
MidiEventCollection
Implements
Inherited Members

Constructors

MidiEventCollection(int, int)

Creates a new Midi Event collection

public MidiEventCollection(int midiFileType, int deltaTicksPerQuarterNote)

Parameters

midiFileType int

Initial file type

deltaTicksPerQuarterNote int

Delta Ticks Per Quarter Note

Properties

DeltaTicksPerQuarterNote

The number of ticks per quarter note

public int DeltaTicksPerQuarterNote { get; }

Property Value

int

this[int]

Gets events on a specific track

public IList<MidiEvent> this[int trackNumber] { get; }

Parameters

trackNumber int

Track number

Property Value

IList<MidiEvent>

The list of events

MidiFileType

The MIDI file type

public int MidiFileType { get; set; }

Property Value

int

StartAbsoluteTime

The absolute time that should be considered as time zero Not directly used here, but useful for timeshifting applications

public long StartAbsoluteTime { get; set; }

Property Value

long

Tracks

The number of tracks

public int Tracks { get; }

Property Value

int

Methods

AddEvent(MidiEvent, int)

Adds an event to the appropriate track depending on file type

public void AddEvent(MidiEvent midiEvent, int originalTrack)

Parameters

midiEvent MidiEvent

The event to be added

originalTrack int

The original (or desired) track number

Remarks

When adding events in type 0 mode, the originalTrack parameter is ignored. If in type 1 mode, it will use the original track number to store the new events. If the original track was 0 and this is a channel based event, it will create new tracks if necessary and put it on the track corresponding to its channel number

AddTrack()

Adds a new track

public IList<MidiEvent> AddTrack()

Returns

IList<MidiEvent>

The new track event list

AddTrack(IList<MidiEvent>)

Adds a new track

public IList<MidiEvent> AddTrack(IList<MidiEvent> initialEvents)

Parameters

initialEvents IList<MidiEvent>

Initial events to add to the new track

Returns

IList<MidiEvent>

The new track event list

Clear()

Clears all events

public void Clear()

GetEnumerator()

Gets an enumerator for the lists of track events

public IEnumerator<IList<MidiEvent>> GetEnumerator()

Returns

IEnumerator<IList<MidiEvent>>

GetTrackEvents(int)

Gets events on a specified track

public IList<MidiEvent> GetTrackEvents(int trackNumber)

Parameters

trackNumber int

Track number

Returns

IList<MidiEvent>

The list of events

PrepareForExport()

Sorts, removes empty tracks and adds end track markers

public void PrepareForExport()

RemoveTrack(int)

Removes a track

public void RemoveTrack(int track)

Parameters

track int

Track number to remove