Search Results for

    Show / Hide Table of Contents

    Class LengthedObjectUtilities

    Extension methods for objects that implement the ILengthedObject interface.
    Inheritance
    object
    LengthedObjectUtilities
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Melanchall.DryWetMidi.Interaction
    Assembly: Melanchall.DryWetMidi.dll
    Syntax
    public static class LengthedObjectUtilities

    Methods

    AtTime<TObject>(IEnumerable<TObject>, ITimeSpan, TempoMap, LengthedObjectPart)

    Filters collection of ILengthedObject to return objects at the specified time.
    Declaration
    public static IEnumerable<TObject> AtTime<TObject>(this IEnumerable<TObject> objects, ITimeSpan time, TempoMap tempoMap, LengthedObjectPart matchBy) where TObject : ILengthedObject
    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.
    LengthedObjectPart matchBy Part of an object which have to be at 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.
    Remarks
    Note that changes made on the objects returned by this method will not be saved to an underlying data source (events collection, track chunk, file). To change properties of lengthed objects and save them you need to use a manager appropriate for an object's type.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • objects is null.
    • time is null.
    • tempoMap is null.
    • One of the objects is null.
    InvalidEnumArgumentException matchBy specified an invalid value.

    AtTime<TObject>(IEnumerable<TObject>, long, LengthedObjectPart)

    Filters collection of ILengthedObject to return objects at the specified time.
    Declaration
    public static IEnumerable<TObject> AtTime<TObject>(this IEnumerable<TObject> objects, long time, LengthedObjectPart matchBy) where TObject : ILengthedObject
    Parameters
    Type Name Description
    IEnumerable<TObject> objects A collection to filter.
    long time Time to filter objects by.
    LengthedObjectPart matchBy Part of an object which have to be at 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.
    Remarks
    Note that changes made on the objects returned by this method will not be saved to an underlying data source (events collection, track chunk, file). To change properties of lengthed objects and save them you need to use a manager appropriate for an object's type.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • objects is null.
    • One of the objects is null.
    ArgumentOutOfRangeException time is negative.
    InvalidEnumArgumentException matchBy specified an invalid value.

    EndAtTime<TObject>(IEnumerable<TObject>, ITimeSpan, TempoMap)

    Filters collection of ILengthedObject to return objects that end at the specified time.
    Declaration
    public static IEnumerable<TObject> EndAtTime<TObject>(this IEnumerable<TObject> objects, ITimeSpan time, TempoMap tempoMap) where TObject : ILengthedObject
    Parameters
    Type Name Description
    IEnumerable<TObject> objects A collection to filter.
    ITimeSpan time End 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 end at the specified time.
    Type Parameters
    Name Description
    TObject The type of the elements of objects.
    Remarks
    Note that changes made on the objects returned by this method will not be saved to an underlying data source (events collection, track chunk, file). To change properties of lengthed objects and save them you need to use a manager appropriate for an object's type.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • objects is null.
    • time is null.
    • tempoMap is null.
    • One of the objects is null.

    EndAtTime<TObject>(IEnumerable<TObject>, long)

    Filters collection of ILengthedObject to return objects that end at the specified time.
    Declaration
    public static IEnumerable<TObject> EndAtTime<TObject>(this IEnumerable<TObject> objects, long time) where TObject : ILengthedObject
    Parameters
    Type Name Description
    IEnumerable<TObject> objects A collection to filter.
    long time End time to filter objects by.
    Returns
    Type Description
    IEnumerable<TObject> A collection that contains objects from the input sequence that end at the specified time.
    Type Parameters
    Name Description
    TObject The type of the elements of objects.
    Remarks
    Note that changes made on the objects returned by this method will not be saved to an underlying data source (events collection, track chunk, file). To change properties of lengthed objects and save them you need to use a manager appropriate for an object's type.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • objects is null.
    • One of the objects is null.
    ArgumentOutOfRangeException time is negative.

    EndTimeAs(ILengthedObject, TimeSpanType, TempoMap)

    Gets end time of an ITimedObject as an instance of time span defined by the specified time span type.
    Declaration
    public static ITimeSpan EndTimeAs(this ILengthedObject obj, TimeSpanType timeType, TempoMap tempoMap)
    Parameters
    Type Name Description
    ILengthedObject obj Object to get end time of.
    TimeSpanType timeType The type of time span to convert the end time of obj to.
    TempoMap tempoMap Tempo map to calculate end time of the obj.
    Returns
    Type Description
    ITimeSpan End time of the specified object as an instance of time span defined by the timeType.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • obj is null.
    • tempoMap is null.
    InvalidEnumArgumentException timeType specified an invalid value.

    EndTimeAs<TTime>(ILengthedObject, TempoMap)

    Gets end time of an ITimedObject as an instance of type that implements the ITimeSpan interface.
    Declaration
    public static TTime EndTimeAs<TTime>(this ILengthedObject obj, TempoMap tempoMap) where TTime : ITimeSpan
    Parameters
    Type Name Description
    ILengthedObject obj Object to get end time of.
    TempoMap tempoMap Tempo map to calculate end time of the obj.
    Returns
    Type Description
    TTime End time of the specified object as an instance of TTime.
    Type Parameters
    Name Description
    TTime Type that will represent the end time of the obj.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • obj is null.
    • tempoMap is null.
    NotSupportedException TTime is not supported.

    LengthAs(ILengthedObject, TimeSpanType, TempoMap)

    Gets length of an ILengthedObject as an instance of type defined by the specified time span type.
    Declaration
    public static ITimeSpan LengthAs(this ILengthedObject obj, TimeSpanType lengthType, TempoMap tempoMap)
    Parameters
    Type Name Description
    ILengthedObject obj Object to get length of.
    TimeSpanType lengthType The type of time span to convert the length of obj to.
    TempoMap tempoMap Tempo map to calculate length of the obj.
    Returns
    Type Description
    ITimeSpan Time of the specified object as an instance of time span defined by the lengthType.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • obj is null.
    • tempoMap is null.
    InvalidEnumArgumentException lengthType specified an invalid value.

    LengthAs<TLength>(ILengthedObject, TempoMap)

    Gets length of an ILengthedObject as an instance of type that implements the ITimeSpan interface.
    Declaration
    public static TLength LengthAs<TLength>(this ILengthedObject obj, TempoMap tempoMap) where TLength : ITimeSpan
    Parameters
    Type Name Description
    ILengthedObject obj Object to get length of.
    TempoMap tempoMap Tempo map to calculate length of the obj.
    Returns
    Type Description
    TLength Length of the specified object as an instance of TLength.
    Type Parameters
    Name Description
    TLength Type that will represent the length of the obj.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • obj is null.
    • tempoMap is null.
    NotSupportedException TLength is not supported.

    SetLength<TObject>(TObject, ITimeSpan, TempoMap)

    Sets length of the specified object in terms of ITimeSpan.
    Declaration
    public static TObject SetLength<TObject>(this TObject obj, ITimeSpan length, TempoMap tempoMap) where TObject : ILengthedObject
    Parameters
    Type Name Description
    TObject obj Object to set length of.
    ITimeSpan length New length of the obj.
    TempoMap tempoMap TempoMap used to calculate new length 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.
    • length is null.
    • tempoMap is null.
    • One of the objects is null.

    StartAtTime<TObject>(IEnumerable<TObject>, ITimeSpan, TempoMap)

    Filters collection of ILengthedObject to return objects that start at the specified time.
    Declaration
    public static IEnumerable<TObject> StartAtTime<TObject>(this IEnumerable<TObject> objects, ITimeSpan time, TempoMap tempoMap) where TObject : ILengthedObject
    Parameters
    Type Name Description
    IEnumerable<TObject> objects A collection to filter.
    ITimeSpan time Start 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 start at the specified time.
    Type Parameters
    Name Description
    TObject The type of the elements of objects.
    Remarks
    Note that changes made on the objects returned by this method will not be saved to an underlying data source (events collection, track chunk, file). To change properties of lengthed objects and save them you need to use a manager appropriate for an object's type.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • objects is null.
    • time is null.
    • tempoMap is null.
    • One of the objects is null.

    StartAtTime<TObject>(IEnumerable<TObject>, long)

    Filters collection of ILengthedObject to return objects that start at the specified time.
    Declaration
    public static IEnumerable<TObject> StartAtTime<TObject>(this IEnumerable<TObject> objects, long time) where TObject : ILengthedObject
    Parameters
    Type Name Description
    IEnumerable<TObject> objects A collection to filter.
    long time Start time to filter objects by.
    Returns
    Type Description
    IEnumerable<TObject> A collection that contains objects from the input sequence that start at the specified time.
    Type Parameters
    Name Description
    TObject The type of the elements of objects.
    Remarks
    Note that changes made on the objects returned by this method will not be saved to an underlying data source (events collection, track chunk, file). To change properties of lengthed objects and save them you need to use a manager appropriate for an object's type.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • objects is null.
    • One of the objects is null.
    ArgumentOutOfRangeException time is negative.
    In this article
    Back to top 2024 / Generated by DocFX