pc:quantize   scheme

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


;; quantize pc
;; Always slelects a higher value before a lower value where distance is equal.
;; arg 1: pitch to quantize to pc
;; arg 2: pc to quantize pitch against
;; returns quantized pitch or #f if non available
(define pc:quantize
   (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)

Back to Index

Similar Entries