mkquant   scheme


Defined in:  https://github.com/lambdamusic/extempore-extensions/blob/main/init/init_makers.xtm

Implementation

;
;
; :MKQUANT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Wrapper around standard pc:quantize
;;
;; Allows passing a scale symbol, or any list of pitches.
;; (original only allows a 0-11 pitch class list) 
;;
; WHEN PASSING A LIST OF PITCH CLASSES
; It behaves just live pc:quantize. The plist (eg scale or chord) defines the random selection options.
;
; WHEN PASSING A QUALITY OR SCALE MODE (eg M/m/aeonian/dorian)
; It defauls to C as root. So all scales are C scales.
; 
;; Examples
; (mkquant 60 'M) ; => 60
; (mkquant 60 (:mkscale d0 'M)) ; => 61 / the 7th degree in dM
;
; NOTE pc:quantize always selects a higher value before a lower value where distance is equal.
; https://extempore.michelepasin.org/def/pc-quantize.html
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define mkquant
    (lambda (pitch-in pitch-list-or-sym)
      (let ((scale pitch-list-or-sym))
        (if	(atom? scale)
            (set! scale (:mkscale 60 pitch-list-or-sym)))
        (pc:quantize pitch-in 
            (map (lambda (x)
                    (modulo x 12))
                scale)      
            ))))


Back to Index