]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/ly-syntax-constructors.scm
Add support for tempo ranges
[lilypond.git] / scm / ly-syntax-constructors.scm
index 92276e745f1ca9fbc31e367b6d02fa7633e82d2e..c34f5c9dd1dc81864acc7d2f143e7ba0d1e5dc7a 100644 (file)
              'element (ly:music-transpose music pitch)))
 
 (define-ly-syntax-simple (tempo text duration tempo)
-  (let ((props (list
-                 (make-property-set 'tempoWholesPerMinute
-                       (ly:moment-mul (ly:make-moment tempo 1)
-                                      (ly:duration-length duration)))
-                 (make-property-set 'tempoUnitDuration duration)
-                 (make-property-set 'tempoUnitCount tempo))))
-    (set! props (cons 
-            (if text (make-property-set 'tempoText text)
-                     (make-property-unset 'tempoText)) 
-            props))
+  (let* ((range-tempo? (pair? tempo))
+        (tempo-count (if range-tempo?
+                         (round (/ (+ (car tempo) (cdr tempo)) 2))
+                         tempo))
+        (props (list
+                (make-property-set 'tempoWholesPerMinute
+                                   (ly:moment-mul (ly:make-moment tempo-count 1)
+                                                  (ly:duration-length duration)))
+                (make-property-set 'tempoUnitDuration duration)
+                (make-property-set 'tempoUnitCount tempo))))
+    (set! props (cons
+                (if text (make-property-set 'tempoText text)
+                     (make-property-unset 'tempoText))
+                props))
     (context-spec-music
-      (make-sequential-music props)
-      'Score)))
+     (make-sequential-music props)
+     'Score)))
 
 (define-ly-syntax-simple (tempoText text)
   (context-spec-music