:tempo   macro


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

Implementation

;
;; :tempo - control metro-beat 'global' tempo
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Args:
; -----
; action: +/- for increment/decrement 
; value: the tempo beats per minute 
; boundary: the min or max value where to stop
;
; DEFAULT MIN = @TODO
; DEFAULT MAX = @TODO
;
; Example:
; --------
;; (:tempo)           -- show current
;; (:tempo 60)       -- [1 args]: set tempo to 60 (up to DEFAULT MAX)
;; (:tempo + 1)       -- [2 args]: increment by 1 (up to DEFAULT MAX)
;; (:tempo '- 1)       -- [2 args]: decrement by -1 (up to DEFAULT MIN)
;; (:tempo '+ 1 50)    -- [3 args]: increment by 1, up to 50
;; (:tempo '- 1 10)    -- [4 args]: decrement by -1, up to 10 
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(impc:aot:do-or-emit
   (define-macro (:tempo . args)
      (cond ((length-equal? args 0)
              ;; eg (:tempo)
              (helper:print-tempo *tempo* 'show))
            ((length-equal? args 1) 
                ;; eg (:tempo 5) ;; Set val
            `(helper:tempo ,(car args) ,(car args) ,(car args) )) 
            ((length-equal? args 2)  
                ;; eg (:tempo '+ 1) => increment by '1' (min/max=default)
                ;; eg (:tempo '- 1) => decrement by '1' (min/max=default)
             `(if (equal? ,(car args) '-) 
                (helper:tempo (- 0 ,(cadr args)) *tempo-lower-limit* *tempo-upper-limit*)
                (helper:tempo ,(cadr args) *tempo-lower-limit* *tempo-upper-limit*)
                ))
            ((length-equal? args 3)  
                ;; eg (:tempo '+ 1 20) => increment by '1' till 20
                ;; eg (:tempo '- 1 20) => decrement by '1' till 20
             `(if (equal? ,(car args) '-)
                (helper:tempo  (- 0 ,(cadr args)) ,(caddr args) *tempo-upper-limit*)
                (helper:tempo  ,(cadr args) *tempo-lower-limit* ,(caddr args))
                ))
            (#t (println "Not enough arguments"))))
)


Back to Index

Similar Entries