:mkmelody   scheme


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

Implementation

;
;
; mkmelody
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Generates a random melody
;
; Args:
; number-of-notes 
; root [default: 60|c4]
; scale-mode [default: 'M]
; steps-variation [default: '(1 -1)]
;
; Example:
; (println (:mkmelody 4 60 'm '(-1) )) ; => (60 58 56 55)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define :mkmelody
  (lambda (len . args)
  ; (println args)
   (cond ((null? args) ;; default / number-of-notes
          (helper:mkmelody:pcrel len c4 'M '(1 -1)))    
          ;
          ((length-equal? args 1) 
           ;; 1 arg = root
           (helper:mkmelody:pcrel len (car args) 'M '(1 -1))) 
          ((length-equal? args 2) 
            ;; 2 args: root AND scale-mode
            (helper:mkmelody:pcrel len (car args) (cadr args) '(1 -1) )) 
          ;
          ((length-equal? args 3) 
            ;; 3 args: root AND scale-mode AND variations-list
            (helper:mkmelody:pcrel len (car args) (cadr args) (caddr args) )) 
          ;
          (else (print 'Error: 'arguments 'could 'not 'be 'resolved.))              
      )
    )          
)


Back to Index

Similar Entries