pc:quantize-low   scheme


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

Implementation

;; quantize pc
;; Always slelects a lower value before a higher value where distance is equal.
;;
;; arg 1: pitch to quantize to pc
;; arg 2: pc to quantize pitch against
;;
;; returns quntized pitch or #f if non available
;;
(define pc:quantize-low
   (lambda (pitch-in pc)
      (let loop ((offset 0)
                 (pitch (real->integer (round pitch-in))))
         (cond ((pc:? (- pitch offset) pc) (- pitch offset))
               ((pc:? (+ pitch offset) pc) (+ pitch offset))
               ((< offset 7) (loop (+ offset 1) pitch))
               (else (log-info "no pc value to quantize to" pitch pc)
                     #f)))))


Back to Index