]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4196: Add a \compound-meter markup command
authorDan Eble <nine.fierce.ballads@gmail.com>
Sat, 15 Nov 2014 14:55:34 +0000 (09:55 -0500)
committerDan Eble <nine.fierce.ballads@gmail.com>
Thu, 27 Nov 2014 02:21:13 +0000 (21:21 -0500)
In addition to supporting the same options as \compoundMeter, the
markup command accepts simple fractions specified as a number-pair.
It also allows single-number time signatures and single-number
components of compound time signatures.

input/regression/markup-compound-meter.ly [new file with mode: 0644]
ly/music-functions-init.ly
scm/time-signature-settings.scm

diff --git a/input/regression/markup-compound-meter.ly b/input/regression/markup-compound-meter.ly
new file mode 100644 (file)
index 0000000..2a8a853
--- /dev/null
@@ -0,0 +1,28 @@
+\version "2.19.16"
+
+\header {
+  texidoc = "The @code{\\compound-meter} markup command can produce various kinds of numeric time signature."
+}
+
+\markup {
+  \vspace #2
+  These are conventional time signatures:
+  \compound-meter #3
+  \compound-meter #'(3 . 4)
+  \compound-meter #'(4 4)
+  (Aren't they pretty?)
+}
+
+\markup {
+  \vspace #2
+  This is single-digit compound time signature:
+  \compound-meter #'((2) (3))
+  (Isn't it pretty?)
+}
+
+\markup {
+  \vspace #2
+  This is an unusual time signature:
+  \compound-meter #'((6.22e23 1) (-4 . 3) (3.14) (9876 5432 0) (-1))
+  (Isn't it pretty?)
+}
index 182f8fdf36334b9acbbba34f33295d62531763cf..203d56584a74a6f323691c1305d184c33179418e 100644 (file)
@@ -279,7 +279,7 @@ as @code{\\compoundMeter #'((3 2 8))} or shorter
                         (ly:moment-main-denominator mlen))))
   #{
     \once \override Timing.TimeSignature.stencil = #(lambda (grob)
-      (grob-interpret-markup grob (format-compound-time args)))
+      (grob-interpret-markup grob (make-compound-meter-markup args)))
     \set Timing.timeSignatureFraction = #timesig
     \set Timing.baseMoment = #beat
     \set Timing.beatStructure = #beatGrouping
index 902a68706726d28944d80fc27a262866124261db..9773f714a6c93bb7e221a2a586628896d52d8ae6 100644 (file)
@@ -296,6 +296,7 @@ a fresh copy of the list-head is made."
 ;;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 ;;; Formatting of complex/compound time signatures
 
+; There ought to be a \join-line sep {...} command
 (define (insert-markups l m)
   (let ((ll (reverse l)))
     (let join-markups ((markups (list (car ll)))
@@ -311,24 +312,56 @@ a fresh copy of the list-head is made."
          (den (car revargs))
          (nums (reverse (cdr revargs))))
     (make-override-markup '(baseline-skip . 0)
-                          (make-number-markup
                            (make-left-column-markup
                             (list (make-center-column-markup
                                    (list (make-line-markup (insert-markups nums "+"))
-                                         den))))))))
+                                         den)))))))
 
-(define (format-complex-compound-time time-sig)
-  (make-override-markup '(baseline-skip . 0)
-                        (make-number-markup
-                         (make-line-markup
-                          (insert-markups (map format-time-fraction time-sig)
-                                          (make-vcenter-markup "+"))))))
+(define (format-time-numerator time-sig)
+  (make-vcenter-markup (number->string (car time-sig))))
 
-(define-public (format-compound-time time-sig)
-  (cond
-   ((not (pair? time-sig)) (null-markup))
-   ((pair? (car time-sig)) (format-complex-compound-time time-sig))
-   (else (format-time-fraction time-sig))))
+(define (format-time-element time-sig)
+  (cond ((number-pair? time-sig)
+         (format-time-fraction (list (car time-sig) (cdr time-sig))))
+        ((pair? (cdr time-sig))
+         (format-time-fraction time-sig))
+        (else
+         (format-time-numerator time-sig))))
+
+(define (format-time-list time-sig)
+  (make-override-markup '(baseline-skip . 0)
+                        (make-line-markup
+                         (insert-markups (map format-time-element time-sig)
+                                         (make-vcenter-markup "+")))))
+
+(define (format-compound-time time-sig)
+  (make-number-markup
+   (cond
+    ((number? time-sig) (format-time-element (list time-sig)))
+    ((number-pair? time-sig)
+     (format-time-element (list (car time-sig) (cdr time-sig))))
+    ((pair? (car time-sig)) (format-time-list time-sig))
+    (else (format-time-element time-sig)))))
+
+(define-markup-command (compound-meter layout props time-sig)
+  (number-or-pair?)
+  #:category music
+  "Draw a numeric time signature.
+
+@lilypond[verbatim,quote]
+\\markup {
+  \\column {
+    \\line { Single number: \\compound-meter #3 }
+    \\line { Conventional: \\compound-meter #'(4 . 4)
+                       or \\compound-meter #'(4 4) }
+    \\line { Compound: \\compound-meter #'(2 3 8) }
+    \\line { Single-number compound: \\compound-meter #'((2) (3)) }
+    \\line { Complex compound: \\compound-meter #'((2 3 8) (3 4)) }
+  }
+}
+@end lilypond
+"
+  (interpret-markup layout props (format-compound-time time-sig)))
 
 
 ;;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%