to-octave   scheme


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

Implementation

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Helper method for 'octave' 
;; example
;; (in-octave 60 1 3) ; +> 12
;; 2023-08-08: always return a pitch even when octave int is wrong
(define to-octave 
  (lambda (pitch min max)
    (if (or (< min 1) (< max 1) (> min 9) (> max 9))
        (begin  
          (log-info "Octaves number should be between 1 and 9. 5=60/c4")
          pitch) 
        (let ((octavemin (* min 12)) 
              (octavemax (* max 12)))   
          (if (or (< pitch octavemin) (> pitch octavemax)) 
            (add (pc:pc pitch) octavemin)  
            pitch)))))


Back to Index