Class Chord
Represents a chord as a set of notes names.
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
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
Exceptions
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
Exceptions
Properties
NotesNames
Gets the chord's notes names.
Declaration
public ICollection<NoteName> NotesNames { get; }
Property Value
RootNoteName
Gets the root note's name of the chord.
Declaration
public NoteName RootNoteName { get; }
Property Value
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
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
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type |
Description |
int |
A hash code for the current object. |
Overrides
GetNames()
Returns collection of names of the current
Chord.
Declaration
public IReadOnlyCollection<string> GetNames()
Returns
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
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
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