From 158a470615ce4ba973bd9f4891bbe23b8812a4be Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Thu, 21 Jul 2016 11:51:44 +0200 Subject: [PATCH 1/1] Issue 4941/1: 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. --- ly/music-functions-init.ly | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index f4f50fafef..ee9fdb8c20 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 = 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))))))) -- 2.39.2