next-or-previous-note-in-scale and scale-sequence functions