Search Results for

    Show / Hide Table of Contents

    Class Rest

    Represents a musical rest. More info in the Getting objects: Rests article.
    Inheritance
    object
    Rest
    Implements
    ILengthedObject
    ITimedObject
    INotifyTimeChanged
    INotifyLengthChanged
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Melanchall.DryWetMidi.Interaction
    Assembly: Melanchall.DryWetMidi.dll
    Syntax
    public sealed class Rest : ILengthedObject, ITimedObject, INotifyTimeChanged, INotifyLengthChanged

    Properties

    EndTime

    Gets the end time of an object.
    Declaration
    public long EndTime { get; }
    Property Value
    Type Description
    long

    Key

    Gets the key of objects the current rest has been built for. Please read Getting objects: Rests article to understand the key concept.
    Declaration
    public object Key { get; }
    Property Value
    Type Description
    object

    Length

    Gets the length of an object.
    Declaration
    public long Length { get; set; }
    Property Value
    Type Description
    long
    Remarks
    Note that the returned value will be in ticks (not seconds, not milliseconds and so on). Please read Time and length article to learn how you can get the length in different representations.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException value is negative.

    Time

    Gets the start time of an object.
    Declaration
    public long Time { get; set; }
    Property Value
    Type Description
    long
    Remarks
    Note that the returned value will be in ticks (not seconds, not milliseconds and so on). Please read Time and length article to learn how you can get the time in different representations.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException value is negative.

    Methods

    Clone()

    Clones object by creating a copy of it.
    Declaration
    public ITimedObject Clone()
    Returns
    Type Description
    ITimedObject Copy of the object.

    Equals(object)

    Determines whether the specified object is equal to the current object.
    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj The object to compare with the current object.
    Returns
    Type Description
    bool true if the specified object is equal to the current object; otherwise, false.
    Overrides
    object.Equals(object)

    GetHashCode()

    Serves as the default hash function.
    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int A hash code for the current object.
    Overrides
    object.GetHashCode()

    Split(long)

    Splits the current object by the specified time.
    Declaration
    public SplitLengthedObject Split(long time)
    Parameters
    Type Name Description
    long time Time to split the object at.
    Returns
    Type Description
    SplitLengthedObject An object containing left and right parts of the split object. Both parts have the same type as the original object.
    Remarks

    If time is less than or equal to time of the object, the left part will be null. If time is greater than or equal to end time of the object, the right part will be null.

    Let's see a simple example. Suppose we have an object with time of 10 and length of 50. The table below shows what left and right parts will be in case of different values of time:

    Time to split atLeft partRight part
    5 null Copy of the object
    10 null Copy of the object
    30 Copy of the object with time of 10 and length of 20Copy of the object with time of 30 and length of 30
    60 Copy of the object null
    70 Copy of the object null

    To learn about other ways to split an object please read Objects splitting article.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException time is negative.

    ToString()

    Returns a string that represents the current object.
    Declaration
    public override string ToString()
    Returns
    Type Description
    string A string that represents the current object.
    Overrides
    object.ToString()

    Events

    LengthChanged

    Occurs when the length of an object has been changed.
    Declaration
    public event EventHandler<LengthChangedEventArgs> LengthChanged
    Event Type
    Type Description
    EventHandler<LengthChangedEventArgs>

    TimeChanged

    Occurs when the time of an object has been changed.
    Declaration
    public event EventHandler<TimeChangedEventArgs> TimeChanged
    Event Type
    Type Description
    EventHandler<TimeChangedEventArgs>

    Operators

    operator ==(Rest, Rest)

    Determines if two Rest objects are equal.
    Declaration
    public static bool operator ==(Rest rest1, Rest rest2)
    Parameters
    Type Name Description
    Rest rest1 The first Rest to compare.
    Rest rest2 The second Rest to compare.
    Returns
    Type Description
    bool true if the rests are equal, false otherwise.

    operator !=(Rest, Rest)

    Determines if two Rest objects are not equal.
    Declaration
    public static bool operator !=(Rest rest1, Rest rest2)
    Parameters
    Type Name Description
    Rest rest1 The first Rest to compare.
    Rest rest2 The second Rest to compare.
    Returns
    Type Description
    bool false if the rests are equal, true otherwise.

    Implements

    ILengthedObject
    ITimedObject
    INotifyTimeChanged
    INotifyLengthChanged

    Extension Methods

    LengthedObjectUtilities.EndTimeAs(ILengthedObject, TimeSpanType, TempoMap)
    LengthedObjectUtilities.EndTimeAs<TTime>(ILengthedObject, TempoMap)
    LengthedObjectUtilities.LengthAs(ILengthedObject, TimeSpanType, TempoMap)
    LengthedObjectUtilities.LengthAs<TLength>(ILengthedObject, TempoMap)
    TimedObjectUtilities.TimeAs(ITimedObject, TimeSpanType, TempoMap)
    TimedObjectUtilities.TimeAs<TTime>(ITimedObject, TempoMap)
    LengthedObjectUtilities.SetLength<TObject>(TObject, ITimeSpan, TempoMap)
    TimedObjectUtilities.SetTime<TObject>(TObject, ITimeSpan, TempoMap)

    See Also

    RestsUtilities
    RestDetectionSettings
    In this article
    Back to top 2024 / Generated by DocFX