@libraz/libcantus - v1.1.0
    Preparing search index...

    Function pitchToScaleDegree

    • Get the scale degree of a pitch, counted from 1: the tonic is degree 1.

      A pitch outside the scale answers -1 rather than 0, so a caller testing the result for a degree cannot mistake the "not in the scale" answer for the tonic.

      Parameters

      • pitch: number

        MIDI pitch or bare pitch class.

      • key: KeyLike

        The key/scale to measure against, as a key name, a key/scale, or a Key.

      Returns number

      The 1-based degree, or -1 if the pitch is not in the scale.