]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4941/1: Optional fraction after \afterGrace command
authorDavid Kastrup <dak@gnu.org>
Thu, 21 Jul 2016 09:51:44 +0000 (11:51 +0200)
committerDavid Kastrup <dak@gnu.org>
Wed, 3 Aug 2016 11:20:38 +0000 (13:20 +0200)
\afterGrace had its fraction determining the position of the aftergrace
notes hardwired to be read from the parser variable afterGraceFraction.
This change here allows for optionally specifying it right as the first
argument of the \afterGrace command.

ly/music-functions-init.ly

index f4f50fafef22fb7248b2612cb6066139fbaaa62c..ee9fdb8c2064b604e8123b0032bdd730f41d5f99 100644 (file)
@@ -56,12 +56,17 @@ addQuote =
    (add-quotable name music))
 
 %% keep these two together
-afterGraceFraction = #(cons 6 8)
+afterGraceFraction = 3/4
 afterGrace =
-#(define-music-function (main grace) (ly:music? ly:music?)
-   (_i "Create @var{grace} note(s) after a @var{main} music expression.")
+#(define-music-function (fraction main grace) ((fraction?) ly:music? ly:music?)
+   (_i "Create @var{grace} note(s) after a @var{main} music expression.
+
+The musical position of the grace expression is after a
+given fraction of the main note's duration has passed.  If
+@var{fraction} is not specified as first argument, it is taken from
+@code{afterGraceFraction} which has a default value of @code{3/4}.")
    (let ((main-length (ly:music-length main))
-         (fraction  (ly:parser-lookup 'afterGraceFraction)))
+         (fraction (or fraction (ly:parser-lookup 'afterGraceFraction))))
      (make-simultaneous-music
       (list
        main
@@ -71,10 +76,8 @@ afterGrace =
          (make-music 'SkipMusic
                      'duration (ly:make-duration
                                 0 0
-                                (* (ly:moment-main-numerator main-length)
-                                   (car fraction))
-                                (* (ly:moment-main-denominator main-length)
-                                   (cdr fraction))))
+                                (* (ly:moment-main main-length)
+                                   (/ (car fraction) (cdr fraction)))))
          (make-music 'GraceMusic
                      'element grace)))))))