mkrandom   scheme


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

Implementation

;
;
; MKRANDOM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Wrapper around standard pc:random 
;;
;; 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 like pc:random. The plist defines (eg scale or chord) 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
; (mkrandom 60 70 'M) ; => 60
; (mkrandom 60 70 (:mkscale 61 'M)) ; => 61
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define mkrandom
    (lambda (lower upper pitch-list-or-sym)
      (let ((scale pitch-list-or-sym))
        (if	(atom? scale)
            (set! scale (:mkscale 60 pitch-list-or-sym)))
        (pc:random lower upper 
            (map (lambda (x)
                    (modulo x 12))
                scale)
            ))))


Back to Index