Search Results for

    Show / Hide Table of Contents

    Class Note

    Represents a note, i.e. note name and octave.
    Inheritance
    object
    Note
    Implements
    IComparable<Note>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Melanchall.DryWetMidi.MusicTheory
    Assembly: Melanchall.DryWetMidi.dll
    Syntax
    public sealed class Note : IComparable<Note>

    Properties

    NoteName

    Gets the note name.
    Declaration
    public NoteName NoteName { get; }
    Property Value
    Type Description
    NoteName

    NoteNumber

    Gets the note number.
    Declaration
    public SevenBitNumber NoteNumber { get; }
    Property Value
    Type Description
    SevenBitNumber

    Octave

    Gets the octave number of a note.
    Declaration
    public int Octave { get; }
    Property Value
    Type Description
    int

    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:

    ValueMeaning
    Less than zeroThis instance precedes other in the sort order.
    ZeroThis instance occurs in the same position in the sort order as other.
    Greater than zeroThis 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
    object.Equals(object)

    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.
    Remarks
    Octave number is specified in scientific pitch notation which means that 4 must be passed to octave to get the middle C.
    Exceptions
    Type Condition
    InvalidEnumArgumentException noteName specified an invalid value.
    ArgumentException Note number is out of range for the specified note name and octave.

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

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

    Transpose(Interval)

    Returns the current Note transposed by the specified Interval.
    Declaration
    public Note Transpose(Interval interval)
    Parameters
    Type Name Description
    Interval interval The Interval to transpose the current Note by.
    Returns
    Type Description
    Note The current Note transposed by the interval.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException Result note's number is out of valid range.

    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
    Type Condition
    ArgumentNullException note is null.
    ArgumentOutOfRangeException Result note's number is out of valid range.

    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
    Type Condition
    ArgumentNullException note is null.
    ArgumentOutOfRangeException Result note's number is out of valid range.

    Implements

    IComparable<T>
    In this article
    Back to top 2024 / Generated by DocFX