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

    Function nearestScaleTone

    • Find the nearest MIDI pitch whose pitch class is in the scale.

      The search expands symmetrically outward from pitch. On a tie (equal distance above and below) the lower pitch is returned.

      Parameters

      • pitch: number

        MIDI pitch to snap.

      • key: KeyLike

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

      Returns number

      The nearest in-scale MIDI pitch.