:mkscale   scheme


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

Implementation

;
;
; :mkscale
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; wrapper around pc:scale with some defaults
;
; Args:
; root    [default: 60]
; mode    [default: 'ionian]
; num-notes [default: 1 octave / 7 notes]
; octaves [default: 1]
;
;
; Example:
; (:mkscale 60) ;=> 7 notes, ionian
; (:mkscale 60 'aeolian) ;=> 7 notes, aeolian
; (:mkscale 60 'm) ;=> 7 notes, aeolian
; (:mkscale 60 'aeolian 5) ;=> 5 notes
; (:mkscale 60 'aeolian 0 3) ;=> 3 octaves (notes arg is ignored)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define :mkscale
  (lambda (root . args)
  ; (println args)
   (cond ((null? args) ;; default
          (add root (pc:scale 0 'ionian)))   
          ;
          ((length-equal? args 1) 
           ;; 1 arg = scale symbol only  
           (add root (pc:scale 0 (car args))))
          ((length-equal? args 2) 
            ;; 2 args: scale, num-notes 
            ;; factor: calc how big the scale before slicing. 5 is the min lenght of a scale. We double that based on on the num-notes parameter
            (let* ((factor (+ (real->integer (/ (cadr args) 5)) 1)) 
                   (s1 (helper:multiply_octaves (pc:scale 0 (car args)) factor)))
              (slice (cadr args) (add root s1))))
          ;
          ((length-equal? args 3) 
            ;; 3 args: scale, num-notes (ignored), octaves 
            ;; added for backward compatibility
            (add root (helper:multiply_octaves (pc:scale 0 (car args)) (caddr args))))
          ;
          (else (print 'Error: 'arguments 'could 'not 'be 'resolved.))              
      )
    )          
)


Back to Index

Similar Entries