Class EventsCollection
Collection of MidiEvent objects.
Inherited Members
Namespace: Melanchall.DryWetMidi.Core
Assembly: Melanchall.DryWetMidi.dll
Syntax
public sealed class EventsCollection : ICollection<MidiEvent>, IEnumerable<MidiEvent>, IEnumerable
Properties
Count
Gets the number of events contained in the collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
IsReadOnly
Gets a value indicating whether the EventsCollection is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
Boolean |
Item[Int32]
Gets or sets the event at the specified index.
Declaration
public MidiEvent this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The zero-based index of the event to get or set. |
Property Value
Type | Description |
---|---|
MidiEvent | The event at the specified index. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | index is less than 0;
or index is equal to or greater than Count. |
ArgumentNullException | value is null . |
Methods
Add(MidiEvent)
Adds an event to the end of collection.
Declaration
public void Add(MidiEvent midiEvent)
Parameters
Type | Name | Description |
---|---|---|
MidiEvent | midiEvent | The event to be added to the end of the collection. |
Remarks
Note that End Of Track events cannot be added into the collection since it may cause inconsistency in a
track chunk structure. End Of Track event will be written to the track chunk automatically on
Write(String, Boolean, MidiFileFormat, WritingSettings).
Exceptions
Type | Condition |
---|---|
ArgumentNullException | midiEvent is null . |
AddRange(IEnumerable<MidiEvent>)
Adds events to the end of collection.
Declaration
public void AddRange(IEnumerable<MidiEvent> events)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<MidiEvent> | events | Events to be added to the end of the collection. |
Remarks
Note that End Of Track events cannot be added into the collection since it may cause inconsistency in a
track chunk structure. End Of Track event will be written to the track chunk automatically on
Write(String, Boolean, MidiFileFormat, WritingSettings).
Exceptions
Type | Condition |
---|---|
ArgumentNullException | events is null . |
Clear()
Removes all events from the EventsCollection.
Declaration
public void Clear()
Contains(MidiEvent)
Determines whether the EventsCollection contains a specific event.
Declaration
public bool Contains(MidiEvent item)
Parameters
Type | Name | Description |
---|---|---|
MidiEvent | item | The event to locate in the EventsCollection. |
Returns
Type | Description |
---|---|
Boolean | true if event is found in the EventsCollection; otherwise, false . |
CopyTo(MidiEvent[], Int32)
Copies the elements of the EventsCollection to an Array,
starting at a particular index.
Declaration
public void CopyTo(MidiEvent[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
MidiEvent[] | array | The one-dimensional Array that is the destination of the elements copied from EventsCollection. The array must have zero-based indexing. |
Int32 | arrayIndex | The zero-based index in array at which copying begins. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | array is null . |
ArgumentOutOfRangeException | arrayIndex is less than 0. |
ArgumentException | The number of elements in the source EventsCollection
is greater than the available space from arrayIndex to the end of the destination
array. |
GetEnumerator()
Returns an enumerator that iterates through the EventsCollection.
Declaration
public IEnumerator<MidiEvent> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<MidiEvent> | An enumerator for the EventsCollection. |
IndexOf(MidiEvent)
Searches for the specified event and returns the zero-based index of the first
occurrence within the entire EventsCollection.
Declaration
public int IndexOf(MidiEvent midiEvent)
Parameters
Type | Name | Description |
---|---|---|
MidiEvent | midiEvent | The event to locate in the EventsCollection. |
Returns
Type | Description |
---|---|
Int32 | The zero-based index of the first occurrence of event within the entire EventsCollection, if found; otherwise, –1. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | midiEvent is null . |
Insert(Int32, MidiEvent)
Inserts an event into the collection at the specified index.
Declaration
public void Insert(int index, MidiEvent midiEvent)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The zero-based index at which the event should be inserted. |
MidiEvent | midiEvent | The event to insert. |
Remarks
Note that End Of Track events cannot be added into the collection since it may cause inconsistency in a
track chunk structure. End Of Track event will be written to the track chunk automatically on
a MIDI file writing.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | midiEvent is null . |
ArgumentOutOfRangeException |
One of the following errors occurred:
|
InsertRange(Int32, IEnumerable<MidiEvent>)
Inserts a set of events into the collection at the specified index.
Declaration
public void InsertRange(int index, IEnumerable<MidiEvent> midiEvents)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The zero-based index at which the events should be inserted. |
IEnumerable<MidiEvent> | midiEvents | The events to insert. |
Remarks
Note that End Of Track events cannot be added into the collection since it may cause inconsistency in a
track chunk structure. End Of Track event will be written to the track chunk automatically on
a MIDI file writing.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | midiEvents is null . |
ArgumentOutOfRangeException |
One of the following errors occurred:
|
Remove(MidiEvent)
Removes the first occurrence of a specific event from the collection.
Declaration
public bool Remove(MidiEvent midiEvent)
Parameters
Type | Name | Description |
---|---|---|
MidiEvent | midiEvent | The event to remove from the collection. The value cannot be null . |
Returns
Type | Description |
---|---|
Boolean | true if event is successfully removed; otherwise, false . This method also returns
false if event was not found in the collection. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | midiEvent is null . |
RemoveAll(Predicate<MidiEvent>)
Removes all the events that match the conditions defined by the specified predicate.
Declaration
public int RemoveAll(Predicate<MidiEvent> match)
Parameters
Type | Name | Description |
---|---|---|
Predicate<MidiEvent> | match | The Predicate<T> delegate that defines the conditions of the events to remove. |
Returns
Type | Description |
---|---|
Int32 | The number of events removed from the EventsCollection. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | match is null . |
RemoveAt(Int32)
Removes the event at the specified index of the collection.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The zero-based index of the event to remove. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | index is less than 0; or index
is equal to or greater than Count. |
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through the EventsCollection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator | An enumerator for the EventsCollection. |