pc:random   scheme


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

Implementation

;; select random pitch from pitch class
;; bounded by lower and upper (inclusive lower exclusive upper)
;;
;; arg 1: lower bound (inclusive)
;; arg 2: upper bound (exclusive)
;; arg 3: pitch class
;;
;; returns #f if no valid pitch is possible
;;
(define pc:random
  (lambda (lower upper pc)
    (if (null? pc) #f
        (let ((choices (filter (lambda (x) (pc:? x pc)) (range lower upper))))
          (if (null? choices) #f
              (random choices))))))


Back to Index

Similar Entries