Search Results for

    Show / Hide Table of Contents

    Class Chord

    Represents a chord as a set of notes names.
    Inheritance
    object
    Chord
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Melanchall.DryWetMidi.MusicTheory
    Assembly: Melanchall.DryWetMidi.dll
    Syntax
    public sealed class Chord

    Constructors

    Chord(NoteName, params Interval[])

    Initializes a new instance of the Chord with the specified root note name and intervals from root one.
    Declaration
    public Chord(NoteName rootNoteName, params Interval[] intervalsFromRoot)
    Parameters
    Type Name Description
    NoteName rootNoteName The root note's name.
    Interval[] intervalsFromRoot Intervals from root note.
    Exceptions
    Type Condition
    InvalidEnumArgumentException rootNoteName specified an invalid value.
    ArgumentNullException intervalsFromRoot is null.

    Chord(NoteName, params NoteName[])

    Initializes a new instance of the Chord with the specified root note name and names of the notes above root one (for example, C and E G).
    Declaration
    public Chord(NoteName rootNoteName, params NoteName[] notesNamesAboveRoot)
    Parameters
    Type Name Description
    NoteName rootNoteName The root note's name.
    NoteName[] notesNamesAboveRoot The set of names of the notes above root one.
    Exceptions
    Type Condition
    InvalidEnumArgumentException

    One of the following errors occurred:

    • rootNoteName specified an invalid value.
    • notesNamesAboveRoot contains an invalid value.

    Chord(NoteName, IEnumerable<Interval>)

    Initializes a new instance of the Chord with the specified root note name and intervals from root one.
    Declaration
    public Chord(NoteName rootNoteName, IEnumerable<Interval> intervalsFromRoot)
    Parameters
    Type Name Description
    NoteName rootNoteName The root note's name.
    IEnumerable<Interval> intervalsFromRoot Intervals from root note.
    Exceptions
    Type Condition
    InvalidEnumArgumentException rootNoteName specified an invalid value.
    ArgumentNullException intervalsFromRoot is null.

    Chord(ICollection<NoteName>)

    Initializes a new instance of the Chord with the specified notes names (for example, C E G).
    Declaration
    public Chord(ICollection<NoteName> notesNames)
    Parameters
    Type Name Description
    ICollection<NoteName> notesNames The set of notes names.
    Exceptions
    Type Condition
    ArgumentNullException notesNames is null.
    InvalidEnumArgumentException notesNames contains an invalid value.
    ArgumentException notesNames is empty collection.

    Properties

    NotesNames

    Gets the chord's notes names.
    Declaration
    public ICollection<NoteName> NotesNames { get; }
    Property Value
    Type Description
    ICollection<NoteName>

    RootNoteName

    Gets the root note's name of the chord.
    Declaration
    public NoteName RootNoteName { get; }
    Property Value
    Type Description
    NoteName

    Methods

    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)

    GetByTriad(NoteName, ChordQuality, params Interval[])

    Creates an instance of the Chord as triad with possible addition of another notes by intervals from the root one.
    Declaration
    public static Chord GetByTriad(NoteName rootNoteName, ChordQuality chordQuality, params Interval[] intervalsFromRoot)
    Parameters
    Type Name Description
    NoteName rootNoteName The root note's name.
    ChordQuality chordQuality Chord's quality.
    Interval[] intervalsFromRoot Intervals from root note.
    Returns
    Type Description
    Chord Chord created by triad with addition of notes defined by intervalsFromRoot.
    Exceptions
    Type Condition
    InvalidEnumArgumentException

    One of the following errors occurred:

    • rootNoteName specified an invalid value.
    • chordQuality specified an invalid value.
    ArgumentNullException intervalsFromRoot is null.

    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()

    GetNames()

    Returns collection of names of the current Chord.
    Declaration
    public IReadOnlyCollection<string> GetNames()
    Returns
    Type Description
    IReadOnlyCollection<string> Collection of names of the current Chord.

    Parse(string)

    Converts the string representation of a musical chord to its Chord equivalent.
    Declaration
    public static Chord Parse(string input)
    Parameters
    Type Name Description
    string input A string containing a chord to convert.
    Returns
    Type Description
    Chord A Chord equivalent to the musical chord contained in input.
    Exceptions
    Type Condition
    ArgumentException input is null or contains white-spaces only.
    FormatException input has invalid format.

    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()

    TryParse(string, out Chord)

    Converts the string representation of a musical chord to its Chord equivalent. A return value indicates whether the conversion succeeded.
    Declaration
    public static bool TryParse(string input, out Chord chord)
    Parameters
    Type Name Description
    string input A string containing a chord to convert.
    Chord chord When this method returns, contains the Chord equivalent of the musical chord contained in input, if the conversion succeeded, or null if the conversion failed. The conversion fails if the input is null or Empty, or is not of the correct format. This parameter is passed uninitialized; any value originally supplied in result will be overwritten.
    Returns
    Type Description
    bool true if input was converted successfully; otherwise, false.

    Operators

    operator ==(Chord, Chord)

    Determines if two Chord objects are equal.
    Declaration
    public static bool operator ==(Chord chord1, Chord chord2)
    Parameters
    Type Name Description
    Chord chord1 The first Chord to compare.
    Chord chord2 The second Chord to compare.
    Returns
    Type Description
    bool true if the chords are equal, false otherwise.

    operator !=(Chord, Chord)

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

    Extension Methods

    ChordUtilities.GetIntervalsBetweenNotes(Chord)
    ChordUtilities.GetIntervalsFromRootNote(Chord)
    ChordUtilities.GetInversions(Chord)
    ChordUtilities.ResolveNotes(Chord, Octave)
    ChordUtilities.ResolveRootNote(Chord, Octave)
    In this article
    Back to top 2024 / Generated by DocFX