From: Dan Eble Date: Sat, 15 Nov 2014 14:55:34 +0000 (-0500) Subject: Issue 4196: Add a \compound-meter markup command X-Git-Tag: release/2.19.16-1~2^2~54^2~29 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=19938f57d5f3e34fe25be79108688fe47ad59a66;p=lilypond.git Issue 4196: Add a \compound-meter markup command 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. --- diff --git a/input/regression/markup-compound-meter.ly b/input/regression/markup-compound-meter.ly new file mode 100644 index 0000000000..2a8a853f50 --- /dev/null +++ b/input/regression/markup-compound-meter.ly @@ -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?) +} diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 182f8fdf36..203d56584a 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -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 diff --git a/scm/time-signature-settings.scm b/scm/time-signature-settings.scm index 902a687067..9773f714a6 100644 --- a/scm/time-signature-settings.scm +++ b/scm/time-signature-settings.scm @@ -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))) ;;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%