Class Note
Represents a note, i.e. note name and octave.
Assembly: Melanchall.DryWetMidi.dll
Syntax
public sealed class Note : IComparable<Note>
Properties
NoteName
Gets the note name.
Declaration
public NoteName NoteName { get; }
Property Value
NoteNumber
Gets the note number.
Declaration
public SevenBitNumber NoteNumber { get; }
Property Value
Octave
Gets the octave number of a note.
Declaration
public int Octave { get; }
Property Value
Methods
CompareTo(Note)
Compares the current instance with another object of the same type and returns
an integer that indicates whether the current instance precedes, follows, or
occurs in the same position in the sort order as the other object.
Declaration
public int CompareTo(Note other)
Parameters
Type |
Name |
Description |
Note |
other |
An object to compare with this instance. |
Returns
Type |
Description |
int |
A value that indicates the relative order of the objects being compared. The
return value has these meanings:
Value | Meaning |
---|
Less than zero | This instance precedes other in the sort order. | Zero | This instance occurs in the same position in the sort order as other . | Greater than zero | This instance follows other in the sort order. |
|
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
Get(SevenBitNumber)
Returns a
Note for the specified note number.
Declaration
public static Note Get(SevenBitNumber noteNumber)
Parameters
Type |
Name |
Description |
SevenBitNumber |
noteNumber |
The number of a note (60 is middle C). |
Returns
Type |
Description |
Note |
A Note for the noteNumber . |
Get(NoteName, int)
Returns a
Note for the specified note name and octave number.
Declaration
public static Note Get(NoteName noteName, int octave)
Parameters
Type |
Name |
Description |
NoteName |
noteName |
The name of a note. |
int |
octave |
The octave number. |
Returns
Type |
Description |
Note |
A Note for the noteName and octave . |
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
Parse(string)
Converts the string representation of a musical note to its
Note equivalent.
Declaration
public static Note Parse(string input)
Parameters
Type |
Name |
Description |
string |
input |
A string containing a note to convert. |
Returns
Type |
Description |
Note |
A Note equivalent to the musical note 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
Transpose(Interval)
Returns the current
Note transposed by the specified
Interval.
Declaration
public Note Transpose(Interval interval)
Parameters
Returns
Type |
Description |
Note |
The current Note transposed by the interval . |
Exceptions
TryParse(string, out Note)
Converts the string representation of a musical note to its
Note equivalent.
A return value indicates whether the conversion succeeded.
Declaration
public static bool TryParse(string input, out Note note)
Parameters
Type |
Name |
Description |
string |
input |
A string containing a note to convert. |
Note |
note |
When this method returns, contains the Note
equivalent of the musical note 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 +(Note, int)
Transposes the specified
Note.
Declaration
public static Note operator +(Note note, int halfSteps)
Parameters
Type |
Name |
Description |
Note |
note |
The Note to transpose. |
int |
halfSteps |
The number of half steps to transpose the note by. |
Returns
Type |
Description |
Note |
The Note which is the note
transposed by the halfSteps . |
Exceptions
operator ==(Note, Note)
Determines if two
Note objects are equal.
Declaration
public static bool operator ==(Note note1, Note note2)
Parameters
Type |
Name |
Description |
Note |
note1 |
The first Note to compare. |
Note |
note2 |
The second Note to compare. |
Returns
Type |
Description |
bool |
true if the notes are equal, false otherwise. |
operator !=(Note, Note)
Determines if two
Note objects are not equal.
Declaration
public static bool operator !=(Note note1, Note note2)
Parameters
Type |
Name |
Description |
Note |
note1 |
The first Note to compare. |
Note |
note2 |
The second Note to compare. |
Returns
Type |
Description |
bool |
false if the notes are equal, true otherwise. |
operator -(Note, int)
Transposes the specified
Note.
Declaration
public static Note operator -(Note note, int halfSteps)
Parameters
Type |
Name |
Description |
Note |
note |
The Note to transpose. |
int |
halfSteps |
The number of half steps to transpose the note by. |
Returns
Type |
Description |
Note |
The Note which is the note
transposed by the halfSteps . |
Exceptions
Implements