pc:relative   scheme


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

Implementation

;; select pitch from pitch class relative to a given pitch
;;
;; 1st: bass pitch
;; 2nd: pc relationship to bass pitch (max is abs 7)
;; 3rd: pitch class
;;
;; example:
;; (pc:relative 64 -2 '(0 2 4 5 7 9 11)) => 60
;; (pc:relative 69 3 '(0 2 4 5 7 9 11)) => 74
;;
(define pc:relative
  (lambda (pitch i pc)
    (set! i (real->integer (round i)))
    (if (= i 0) pitch
  (let ((cnt_op (if (negative? i) - +)))
    (let loop ((p (cnt_op pitch 1)) (cnt 0))
      (if (pc:? p pc) (set! cnt (cnt_op cnt 1)))
      (if (= cnt i) p
    (loop (cnt_op p 1) cnt)))))))


Back to Index