@libraz/libcantus - v0.9.3
    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: KeyScale

        The key/scale to snap to.

      Returns number

      The nearest in-scale MIDI pitch.