pc:find-closest   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/core/pc_ivl.xtm

Implementation

;; returns the pitch in plst that is closest to the pc set
;; if multiple pitches in plst are the closest return the first
(define pc:find-closest
   (lambda (plst pc)
      (cdar (cl:sort (map (lambda (p)
                            (cons (pc:distance p pc) p))
                         plst)
                     (lambda (a b) (if (< (car a) (car b)) #t #f))))))


Back to Index