octave   scheme


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

Implementation

;; OCTAVE 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Move a pitch to a different octave range, within with min/max boundaries.
;
;; arg1: pitch or pitch-list
;; arg2: min boundary (if not provided, 1)
;; arg3: max boundary (if not provided, min +1)
;
;;  Octave 1 = c0 = 12  // 1st octave starts
;;  Octave 2 = c1 = 24  
;;  Octave 3 = c2 = 36  // 3rd octave starts
;;  Octave 4 = c3 = 48
;;  Octave 5 = c4 = 60  // 5th octave starts
;;  Octave 6 = c5 = 72
;;  Octave 7 = c6 = 84  // 7th octave starts
;;  Octave 8 = c7 = 96
;;  Octave 9 = c8 = 108
;
;; Examples
; (octave 10) ; +> 22 / simply add 12 semitones
; (octave '(10 20)) ; +> (22 32) / add 12 semitones to a list
; (octave 60 3) ; 36 / move to 3rd octave
; (octave 60 3 6) ; 60 / move to octave between 3rd and 6th
; (octave '(60 72) 3 6) ; (60 72) / move list to octave between 3rd and 6th 
;;
(define octave
  (lambda (plist . args)
  ; (println args)
   (cond ((null? args) 
          ;; 1 arg  - plist => intervallo di ottava
          (add 12 plist))   
          ((length-equal? args 1) 
           ;; 2 arg = plist and min boundary => max boundary inferred as min+1
           (if (list? plist) 
                  (map (lambda (x)
                      (to-octave x (car args) (+ (car args) 1)))  
                    plist) 
                (to-octave plist (car args) (+ (car args) 1))) 
           )


Back to Index

Similar Entries