lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optional fraction after \afterGrace command (issue 304200043 by addr


From: dak
Subject: Re: Optional fraction after \afterGrace command (issue 304200043 by address@hidden)
Date: Fri, 22 Jul 2016 00:55:54 -0700

Reviewers: lemzwerg, mark_opus11.net,

Message:
On 2016/07/22 07:41:00, mark_opus11.net wrote:
On 2016/07/22 04:26:01, lemzwerg wrote:
> LGMT. Thanks a lot!

Might it be a good idea to keep one example using the old define
method, which
is still more convenient for setting the value for multiple usages of
\afterGrace (or globally)?

Frankly, I decided against doing so since redefining parser behavior by
resetting a global variable controlling its behavior in the middle of a
music expression is a complete abomination.  This is different to how
\tupletSpan (or its equivalent \override) works since \tupletSpan
becomes a _part_ of the music expression.

That's not really something we want to paint as a user interface.  It's
also impossible to reflect with \displayLilyMusic.

I actually asked myself the question "might it be a good idea to keep
one example using the old define method" and my personal answer to that
question ended up being "no".  If anything, i was rather tempted
undocumenting it completely but then the arbitrary default value of 3/4
needed to get mentioned so that one would be able to understand how
custom values were related.  And I decided that just mentioning where
this default was stored would provide a comparatively small opening in
the can of worms.

So this was a conscious decision on my part and I'll require some
convincing to revert.

Description:
Optional fraction after \afterGrace command

\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.


Also contains commit:

NR: show optional \afterGrace argument

Please review this at https://codereview.appspot.com/304200043/

Affected files (+21, -16 lines):
  M Documentation/notation/rhythms.itely
  M ly/music-functions-init.ly


Index: Documentation/notation/rhythms.itely
diff --git a/Documentation/notation/rhythms.itely b/Documentation/notation/rhythms.itely index d3263d4f6a43f93d6e6c50e1f78868aa80bb13e0..c08e4da361f9d9517a49a5e25a8183398f667064 100644
--- a/Documentation/notation/rhythms.itely
+++ b/Documentation/notation/rhythms.itely
@@ -3433,10 +3433,14 @@ notes following the main note.
 @end lilypond

 This will put the grace notes after a space lasting 3/4 of the
-length of the main note.  The default fraction 3/4 can be changed by
-setting @code{afterGraceFraction}.  The following example shows
-the results from setting the space at the default,  at 15/16, and
-finally at 1/2 of the main note.
+length of the main note.  The default fraction of @code{3/4} is
+stored in the parser variable @code{afterGraceFraction}.
+Fractions differing from the default can be specified right after
+the @code{\afterGrace} command.
+
+The following example shows the results from setting with the
+default space, setting it at @code{15/16}, and finally at
address@hidden/2} of the main note.

 @lilypond[quote,verbatim]
 <<
@@ -3444,12 +3448,10 @@ finally at 1/2 of the main note.
     c''1 \afterGrace d1 { c16[ d] } c1
   }
   \new Staff \relative {
-    #(define afterGraceFraction (cons 15 16))
-    c''1 \afterGrace d1 { c16[ d] } c1
+    c''1 \afterGrace 15/16 d1 { c16[ d] } c1
   }
   \new Staff \relative {
-    #(define afterGraceFraction (cons 1 2))
-    c''1 \afterGrace d1 { c16[ d] } c1
+    c''1 \afterGrace 1/2 d1 { c16[ d] } c1
   }
 >>
 @end lilypond
Index: ly/music-functions-init.ly
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index f4f50fafef22fb7248b2612cb6066139fbaaa62c..37f76bbe1f8c6e19bb57a8c7ff7f4cd34ef872dd 100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -56,12 +56,17 @@ addQuote =
    (add-quotable name music))

 %% keep these two together
-afterGraceFraction = #(cons 6 8)
+afterGraceFraction = 6/8
 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
address@hidden is not specified as first argument, it is taken from
address@hidden which has a default value of @code{6/8}.")
    (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)))))))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]