Class TimedObjectUtilities
Extension methods for objects that implement the
ITimedObject interface.
Inheritance
TimedObjectUtilities
Assembly: Melanchall.DryWetMidi.dll
Syntax
public static class TimedObjectUtilities
Methods
AddObjects(EventsCollection, IEnumerable<ITimedObject>)
Declaration
public static void AddObjects(this EventsCollection eventsCollection, IEnumerable<ITimedObject> timedObjects)
Parameters
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
eventsCollection is null . -
timedObjects is null .
|
AddObjects(TrackChunk, IEnumerable<ITimedObject>)
Adds the specified collection of objects to
TrackChunk.
Declaration
public static void AddObjects(this TrackChunk trackChunk, IEnumerable<ITimedObject> timedObjects)
Parameters
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
trackChunk is null . -
timedObjects is null .
|
AtTime<TObject>(IEnumerable<TObject>, ITimeSpan, TempoMap)
Filters collection of
ITimedObject to return objects at the specified time.
Declaration
public static IEnumerable<TObject> AtTime<TObject>(this IEnumerable<TObject> objects, ITimeSpan time, TempoMap tempoMap) where TObject : ITimedObject
Parameters
Type |
Name |
Description |
IEnumerable<TObject> |
objects |
A collection to filter. |
ITimeSpan |
time |
Time to filter objects by. |
TempoMap |
tempoMap |
Tempo map to filter objects by time . |
Returns
Type |
Description |
IEnumerable<TObject> |
A collection that contains objects from the input sequence that are at the specified time. |
Type Parameters
Name |
Description |
TObject |
The type of the elements of objects . |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
objects is null . -
time is null . -
tempoMap is null .
|
AtTime<TObject>(IEnumerable<TObject>, long)
Filters collection of
ITimedObject to return objects at the specified time.
Declaration
public static IEnumerable<TObject> AtTime<TObject>(this IEnumerable<TObject> objects, long time) where TObject : ITimedObject
Parameters
Type |
Name |
Description |
IEnumerable<TObject> |
objects |
A collection to filter. |
long |
time |
Time to filter objects by. |
Returns
Type |
Description |
IEnumerable<TObject> |
A collection that contains objects from the input sequence that are at the specified time. |
Type Parameters
Name |
Description |
TObject |
The type of the elements of objects . |
Exceptions
ProcessObjects(EventsCollection, ObjectType, Action<ITimedObject>, ObjectDetectionSettings, ObjectProcessingHint)
Declaration
public static int ProcessObjects(this EventsCollection eventsCollection, ObjectType objectType, Action<ITimedObject> action, ObjectDetectionSettings settings = null, ObjectProcessingHint hint = ObjectProcessingHint.Default)
Parameters
Returns
Type |
Description |
int |
Count of processed objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
eventsCollection is null . -
action is null .
|
ProcessObjects(EventsCollection, ObjectType, Action<ITimedObject>, Predicate<ITimedObject>, ObjectDetectionSettings, ObjectProcessingHint)
Declaration
public static int ProcessObjects(this EventsCollection eventsCollection, ObjectType objectType, Action<ITimedObject> action, Predicate<ITimedObject> match, ObjectDetectionSettings settings = null, ObjectProcessingHint hint = ObjectProcessingHint.Default)
Parameters
Type |
Name |
Description |
EventsCollection |
eventsCollection |
EventsCollection to search for objects to process. |
ObjectType |
objectType |
Types of objects to process (for example, ObjectType.Chord | ObjectType.TimedEvent ). |
Action<ITimedObject> |
action |
The action to perform on each object contained in the
eventsCollection . |
Predicate<ITimedObject> |
match |
The predicate that defines the conditions of an object to process. Predicate
should return true for an object to process. |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
ObjectProcessingHint |
hint |
Hint which tells the processing algorithm how it can optimize its performance.
The default value is Default. |
Returns
Type |
Description |
int |
Count of processed objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
eventsCollection is null . -
action is null . -
match is null .
|
ProcessObjects(MidiFile, ObjectType, Action<ITimedObject>, ObjectDetectionSettings, ObjectProcessingHint)
Declaration
public static int ProcessObjects(this MidiFile file, ObjectType objectType, Action<ITimedObject> action, ObjectDetectionSettings settings = null, ObjectProcessingHint hint = ObjectProcessingHint.Default)
Parameters
Type |
Name |
Description |
MidiFile |
file |
MidiFile to search for objects to process. |
ObjectType |
objectType |
Types of objects to process (for example, ObjectType.Chord | ObjectType.TimedEvent ). |
Action<ITimedObject> |
action |
The action to perform on each object contained in the
file . |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
ObjectProcessingHint |
hint |
Hint which tells the processing algorithm how it can optimize its performance.
The default value is Default. |
Returns
Type |
Description |
int |
Count of processed objects. |
Exceptions
ProcessObjects(MidiFile, ObjectType, Action<ITimedObject>, Predicate<ITimedObject>, ObjectDetectionSettings, ObjectProcessingHint)
Performs the specified action on objects contained in
MidiFile. Objects
for processing will be selected by the specified object type and matching predicate. More info in the
Processing objects: ProcessObjects article.
Declaration
public static int ProcessObjects(this MidiFile file, ObjectType objectType, Action<ITimedObject> action, Predicate<ITimedObject> match, ObjectDetectionSettings settings = null, ObjectProcessingHint hint = ObjectProcessingHint.Default)
Parameters
Type |
Name |
Description |
MidiFile |
file |
MidiFile to search for objects to process. |
ObjectType |
objectType |
Types of objects to process (for example, ObjectType.Chord | ObjectType.TimedEvent ). |
Action<ITimedObject> |
action |
The action to perform on each object contained in the
file . |
Predicate<ITimedObject> |
match |
The predicate that defines the conditions of an object to process. Predicate
should return true for an object to process. |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
ObjectProcessingHint |
hint |
Hint which tells the processing algorithm how it can optimize its performance.
The default value is Default. |
Returns
Type |
Description |
int |
Count of processed objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
file is null . -
action is null . -
match is null .
|
ProcessObjects(TrackChunk, ObjectType, Action<ITimedObject>, ObjectDetectionSettings, ObjectProcessingHint)
Declaration
public static int ProcessObjects(this TrackChunk trackChunk, ObjectType objectType, Action<ITimedObject> action, ObjectDetectionSettings settings = null, ObjectProcessingHint hint = ObjectProcessingHint.Default)
Parameters
Type |
Name |
Description |
TrackChunk |
trackChunk |
TrackChunk to search for objects to process. |
ObjectType |
objectType |
Types of objects to process (for example, ObjectType.Chord | ObjectType.TimedEvent ). |
Action<ITimedObject> |
action |
The action to perform on each object contained in the
trackChunk . |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
ObjectProcessingHint |
hint |
Hint which tells the processing algorithm how it can optimize its performance.
The default value is Default. |
Returns
Type |
Description |
int |
Count of processed objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
trackChunk is null . -
action is null .
|
ProcessObjects(TrackChunk, ObjectType, Action<ITimedObject>, Predicate<ITimedObject>, ObjectDetectionSettings, ObjectProcessingHint)
Performs the specified action on objects contained in the
TrackChunk. Objects
for processing will be selected by the specified object type and matching predicate. More info in the
Processing objects: ProcessObjects article.
Declaration
public static int ProcessObjects(this TrackChunk trackChunk, ObjectType objectType, Action<ITimedObject> action, Predicate<ITimedObject> match, ObjectDetectionSettings settings = null, ObjectProcessingHint hint = ObjectProcessingHint.Default)
Parameters
Type |
Name |
Description |
TrackChunk |
trackChunk |
TrackChunk to search for objects to process. |
ObjectType |
objectType |
Types of objects to process (for example, ObjectType.Chord | ObjectType.TimedEvent ). |
Action<ITimedObject> |
action |
The action to perform on each object contained in the
trackChunk . |
Predicate<ITimedObject> |
match |
The predicate that defines the conditions of an object to process. Predicate
should return true for an object to process. |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
ObjectProcessingHint |
hint |
Hint which tells the processing algorithm how it can optimize its performance.
The default value is Default. |
Returns
Type |
Description |
int |
Count of processed objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
trackChunk is null . -
action is null . -
match is null .
|
ProcessObjects(IEnumerable<TrackChunk>, ObjectType, Action<ITimedObject>, ObjectDetectionSettings, ObjectProcessingHint)
Declaration
public static int ProcessObjects(this IEnumerable<TrackChunk> trackChunks, ObjectType objectType, Action<ITimedObject> action, ObjectDetectionSettings settings = null, ObjectProcessingHint hint = ObjectProcessingHint.Default)
Parameters
Type |
Name |
Description |
IEnumerable<TrackChunk> |
trackChunks |
The collection of TrackChunk to search for objects to process. |
ObjectType |
objectType |
Types of objects to process (for example, ObjectType.Chord | ObjectType.TimedEvent ). |
Action<ITimedObject> |
action |
The action to perform on each object contained in the
trackChunks . |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
ObjectProcessingHint |
hint |
Hint which tells the processing algorithm how it can optimize its performance.
The default value is Default. |
Returns
Type |
Description |
int |
Count of processed objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
trackChunks is null . -
action is null .
|
ProcessObjects(IEnumerable<TrackChunk>, ObjectType, Action<ITimedObject>, Predicate<ITimedObject>, ObjectDetectionSettings, ObjectProcessingHint)
Performs the specified action on objects contained in the collection of
TrackChunk. Objects
for processing will be selected by the specified object type and matching predicate. More info in the
Processing objects: ProcessObjects article.
Declaration
public static int ProcessObjects(this IEnumerable<TrackChunk> trackChunks, ObjectType objectType, Action<ITimedObject> action, Predicate<ITimedObject> match, ObjectDetectionSettings settings = null, ObjectProcessingHint hint = ObjectProcessingHint.Default)
Parameters
Type |
Name |
Description |
IEnumerable<TrackChunk> |
trackChunks |
The collection of TrackChunk to search for objects to process. |
ObjectType |
objectType |
Types of objects to process (for example, ObjectType.Chord | ObjectType.TimedEvent ). |
Action<ITimedObject> |
action |
The action to perform on each object contained in the
trackChunks . |
Predicate<ITimedObject> |
match |
The predicate that defines the conditions of an object to process. Predicate
should return true for an object to process. |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
ObjectProcessingHint |
hint |
Hint which tells the processing algorithm how it can optimize its performance.
The default value is Default. |
Returns
Type |
Description |
int |
Count of processed objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
trackChunks is null . -
action is null . -
match is null .
|
RemoveObjects(EventsCollection, ObjectType, ObjectDetectionSettings)
Declaration
public static int RemoveObjects(this EventsCollection eventsCollection, ObjectType objectType, ObjectDetectionSettings settings = null)
Parameters
Returns
Type |
Description |
int |
Count of removed objects. |
Exceptions
RemoveObjects(EventsCollection, ObjectType, Predicate<ITimedObject>, ObjectDetectionSettings)
Declaration
public static int RemoveObjects(this EventsCollection eventsCollection, ObjectType objectType, Predicate<ITimedObject> match, ObjectDetectionSettings settings = null)
Parameters
Type |
Name |
Description |
EventsCollection |
eventsCollection |
EventsCollection to search for objects to remove. |
ObjectType |
objectType |
Types of objects to remove (for example, ObjectType.Chord | ObjectType.Note ). |
Predicate<ITimedObject> |
match |
The predicate that defines the conditions of an object to remove. Predicate
should return true for an object that must be removed. |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
Returns
Type |
Description |
int |
Count of removed objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
eventsCollection is null . -
match is null .
|
RemoveObjects(MidiFile, ObjectType, ObjectDetectionSettings)
Declaration
public static int RemoveObjects(this MidiFile file, ObjectType objectType, ObjectDetectionSettings settings = null)
Parameters
Type |
Name |
Description |
MidiFile |
file |
MidiFile to search for objects to remove. |
ObjectType |
objectType |
Types of objects to remove (for example, ObjectType.Chord | ObjectType.Note ). |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
Returns
Type |
Description |
int |
Count of removed objects. |
Exceptions
RemoveObjects(MidiFile, ObjectType, Predicate<ITimedObject>, ObjectDetectionSettings)
Declaration
public static int RemoveObjects(this MidiFile file, ObjectType objectType, Predicate<ITimedObject> match, ObjectDetectionSettings settings = null)
Parameters
Type |
Name |
Description |
MidiFile |
file |
MidiFile to search for objects to remove. |
ObjectType |
objectType |
Types of objects to remove (for example, ObjectType.Chord | ObjectType.Note ). |
Predicate<ITimedObject> |
match |
The predicate that defines the conditions of an object to remove. Predicate
should return true for an object that must be removed. |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
Returns
Type |
Description |
int |
Count of removed objects. |
Exceptions
RemoveObjects(TrackChunk, ObjectType, ObjectDetectionSettings)
Declaration
public static int RemoveObjects(this TrackChunk trackChunk, ObjectType objectType, ObjectDetectionSettings settings = null)
Parameters
Type |
Name |
Description |
TrackChunk |
trackChunk |
TrackChunk to search for objects to remove. |
ObjectType |
objectType |
Types of objects to remove (for example, ObjectType.Chord | ObjectType.Note ). |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
Returns
Type |
Description |
int |
Count of removed objects. |
Exceptions
RemoveObjects(TrackChunk, ObjectType, Predicate<ITimedObject>, ObjectDetectionSettings)
Declaration
public static int RemoveObjects(this TrackChunk trackChunk, ObjectType objectType, Predicate<ITimedObject> match, ObjectDetectionSettings settings = null)
Parameters
Type |
Name |
Description |
TrackChunk |
trackChunk |
TrackChunk to search for objects to remove. |
ObjectType |
objectType |
Types of objects to remove (for example, ObjectType.Chord | ObjectType.Note ). |
Predicate<ITimedObject> |
match |
The predicate that defines the conditions of an object to remove. Predicate
should return true for an object that must be removed. |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
Returns
Type |
Description |
int |
Count of removed objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
trackChunk is null . -
match is null .
|
RemoveObjects(IEnumerable<TrackChunk>, ObjectType, ObjectDetectionSettings)
Declaration
public static int RemoveObjects(this IEnumerable<TrackChunk> trackChunks, ObjectType objectType, ObjectDetectionSettings settings = null)
Parameters
Returns
Type |
Description |
int |
Count of removed objects. |
Exceptions
RemoveObjects(IEnumerable<TrackChunk>, ObjectType, Predicate<ITimedObject>, ObjectDetectionSettings)
Declaration
public static int RemoveObjects(this IEnumerable<TrackChunk> trackChunks, ObjectType objectType, Predicate<ITimedObject> match, ObjectDetectionSettings settings = null)
Parameters
Type |
Name |
Description |
IEnumerable<TrackChunk> |
trackChunks |
The collection of TrackChunk to search for objects to remove. |
ObjectType |
objectType |
Types of objects to remove (for example, ObjectType.Chord | ObjectType.Note ). |
Predicate<ITimedObject> |
match |
The predicate that defines the conditions of an object to remove. Predicate
should return true for an object that must be removed. |
ObjectDetectionSettings |
settings |
Settings according to which objects should be detected and built. |
Returns
Type |
Description |
int |
Count of removed objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
trackChunks is null . -
match is null .
|
SetTime<TObject>(TObject, ITimeSpan, TempoMap)
Sets time of the specified object in terms of
ITimeSpan.
Declaration
public static TObject SetTime<TObject>(this TObject obj, ITimeSpan time, TempoMap tempoMap) where TObject : ITimedObject
Parameters
Type |
Name |
Description |
TObject |
obj |
Object to set time of. |
ITimeSpan |
time |
New time of the obj . |
TempoMap |
tempoMap |
TempoMap used to calculate new time in ticks. |
Returns
Type |
Description |
TObject |
The same object the method was called on. |
Type Parameters
Name |
Description |
TObject |
The type of the obj . |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
obj is null . -
time is null . -
tempoMap is null . - One of the objects is
null .
|
TimeAs(ITimedObject, TimeSpanType, TempoMap)
Gets time of an
ITimedObject as an instance of time span defined by the
specified time span type.
Declaration
public static ITimeSpan TimeAs(this ITimedObject obj, TimeSpanType timeType, TempoMap tempoMap)
Parameters
Type |
Name |
Description |
ITimedObject |
obj |
Object to get time of. |
TimeSpanType |
timeType |
The type of time span to convert the time of obj to. |
TempoMap |
tempoMap |
Tempo map to calculate time of the obj . |
Returns
Type |
Description |
ITimeSpan |
Time of the specified object as an instance of time span defined by the
timeType . |
Exceptions
TimeAs<TTime>(ITimedObject, TempoMap)
Declaration
public static TTime TimeAs<TTime>(this ITimedObject obj, TempoMap tempoMap) where TTime : ITimeSpan
Parameters
Type |
Name |
Description |
ITimedObject |
obj |
Object to get time of. |
TempoMap |
tempoMap |
Tempo map to calculate time of the obj . |
Returns
Type |
Description |
TTime |
Time of the specified object as an instance of TTime . |
Type Parameters
Name |
Description |
TTime |
Type that will represent the time of the obj . |
Exceptions
ToFile(IEnumerable<ITimedObject>)
Creates a MIDI file with the specified timed objects.
Declaration
public static MidiFile ToFile(this IEnumerable<ITimedObject> timedObjects)
Parameters
Returns
Exceptions
ToTrackChunk(IEnumerable<ITimedObject>)
Creates a track chunk with the specified objects.
Declaration
public static TrackChunk ToTrackChunk(this IEnumerable<ITimedObject> timedObjects)
Parameters
Returns
Exceptions