Search Results for

    Show / Hide Table of Contents

    Class Chord

    Represents a musical chord.
    Inheritance
    object
    Chord
    Implements
    ILengthedObject
    ITimedObject
    IMusicalObject
    INotifyTimeChanged
    INotifyLengthChanged
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Melanchall.DryWetMidi.Interaction
    Assembly: Melanchall.DryWetMidi.dll
    Syntax
    public class Chord : ILengthedObject, ITimedObject, IMusicalObject, INotifyTimeChanged, INotifyLengthChanged

    Constructors

    Chord()

    Initializes a new instance of the Chord.
    Declaration
    public Chord()

    Chord(params Note[])

    Initializes a new instance of the Chord with the specified collection of notes.
    Declaration
    public Chord(params Note[] notes)
    Parameters
    Type Name Description
    Note[] notes Notes to combine into a chord.
    Exceptions
    Type Condition
    ArgumentNullException notes is null.

    Chord(IEnumerable<Note>)

    Initializes a new instance of the Chord with the specified collection of notes.
    Declaration
    public Chord(IEnumerable<Note> notes)
    Parameters
    Type Name Description
    IEnumerable<Note> notes Notes to combine into a chord.
    Exceptions
    Type Condition
    ArgumentNullException notes is null.

    Chord(IEnumerable<Note>, long)

    Initializes a new instance of the Chord with the specified collection of notes and chord time.
    Declaration
    public Chord(IEnumerable<Note> notes, long time)
    Parameters
    Type Name Description
    IEnumerable<Note> notes Notes to combine into a chord.
    long time Time of the chord which is time of the earliest note of the notes.
    Exceptions
    Type Condition
    ArgumentNullException notes is null.
    ArgumentOutOfRangeException time is negative.

    Properties

    Channel

    Gets or sets channel to play the chord on.
    Declaration
    public FourBitNumber Channel { get; set; }
    Property Value
    Type Description
    FourBitNumber
    Exceptions
    Type Condition
    InvalidOperationException

    One of the following errors occurred:

    • Unable to get channel since a chord doesn't contain notes.
    • Unable to get channel since chord's notes have different Velocity.

    EndTime

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

    Length

    Gets or sets the length of the chord in units defined by the time division of a MIDI file.
    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.

    Notes

    Gets a TimedObjectsCollection<TObject> that contains notes of this chord.
    Declaration
    public TimedObjectsCollection<Note> Notes { get; }
    Property Value
    Type Description
    TimedObjectsCollection<Note>

    OffVelocity

    Gets or sets velocity of the underlying NoteOffEvent events of a chord's notes.
    Declaration
    public SevenBitNumber OffVelocity { get; set; }
    Property Value
    Type Description
    SevenBitNumber
    Exceptions
    Type Condition
    InvalidOperationException

    One of the following errors occurred:

    • Unable to get off velocity since a chord doesn't contain notes.
    • Unable to get off velocity since chord's notes have different OffVelocity.

    Time

    Gets or sets absolute time of the chord in units defined by the time division of a MIDI file.
    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.

    Velocity

    Gets or sets velocity of the underlying NoteOnEvent events of a chord's notes.
    Declaration
    public SevenBitNumber Velocity { get; set; }
    Property Value
    Type Description
    SevenBitNumber
    Exceptions
    Type Condition
    InvalidOperationException

    One of the following errors occurred:

    • Unable to get velocity since a chord doesn't contain notes.
    • Unable to get velocity since chord's notes have different Velocity.

    Methods

    Clone()

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

    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>

    NotesCollectionChanged

    Occurs when notes collection changes.
    Declaration
    public event TimedObjectsCollectionChangedEventHandler<Note> NotesCollectionChanged
    Event Type
    Type Description
    TimedObjectsCollectionChangedEventHandler<Note>

    TimeChanged

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

    Implements

    ILengthedObject
    ITimedObject
    IMusicalObject
    INotifyTimeChanged
    INotifyLengthChanged

    Extension Methods

    ChordsManagingUtilities.GetMusicTheoryChord(Chord)
    LengthedObjectUtilities.SetLength<TObject>(TObject, ITimeSpan, TempoMap)
    TimedObjectUtilities.SetTime<TObject>(TObject, ITimeSpan, TempoMap)
    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)
    In this article
    Back to top 2024 / Generated by DocFX