diff options
author | David Kastrup <dak@gnu.org> | 2016-07-21 11:51:44 +0200 |
---|---|---|
committer | David Kastrup <dak@gnu.org> | 2016-08-03 13:20:38 +0200 |
commit | 158a470615ce4ba973bd9f4891bbe23b8812a4be (patch) | |
tree | cbc0036e81fd49462fe130f5c09699961225ef86 | |
parent | 6cceacc45f484426b17798cf15d79a48ec12141d (diff) |
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.
-rw-r--r-- | ly/music-functions-init.ly | 19 |
1 files 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))))))) |