From ddaf8f8c52271d1e9bee0a72a4f0ad4e23b1e597 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Thu, 10 Jan 2013 00:32:41 +0100 Subject: [PATCH] Issue 3095: \tuplet and \tupletSpan to replace \times and tupletSpannerDuration \tuplet: Scale the given @var{music} to tuplets. @var{ratio} is a fraction that specifies how many notes are played in place of the nominal value: it will be @samp{3/2} for triplets, namely three notes being played in place of two. If the optional duration @var{tuplet-span} is specified, it is used instead of @code{tupletSpannerDuration} for grouping the tuplets. For example, @example \tuplet 3/2 4 @{ c8 c c c c c @} @end example will result in two groups of three tuplets, each group lasting for a quarter note. tupletSpan: Set @code{tupletSpannerDuration}, the length into which @code{\tuplet} without an explicit @samp{tuplet-span} argument of its own will group its tuplets, to the duration @var{tuplet-span}. To revert to the default of not subdividing the contents of a @code{\tuplet} command without explicit @samp{tuplet-span}, use @example \tupletSpan \default @end example --- ly/music-functions-init.ly | 41 +++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 936d683e96..c063b9585d 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -18,7 +18,7 @@ %%%% You should have received a copy of the GNU General Public License %%%% along with LilyPond. If not, see . -\version "2.17.6" +\version "2.17.11" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1342,6 +1342,45 @@ transposition = (ly:pitch-negate pitch)) 'Staff)) +tuplet = +#(define-music-function (parser location ratio tuplet-span music) + (fraction? (ly:duration? '()) ly:music?) + (_i "Scale the given @var{music} to tuplets. @var{ratio} is a +fraction that specifies how many notes are played in place of the +nominal value: it will be @samp{3/2} for triplets, namely three notes +being played in place of two. If the optional duration +@var{tuplet-span} is specified, it is used instead of +@code{tupletSpannerDuration} for grouping the tuplets. +For example, +@example +\\tuplet 3/2 4 @{ c8 c c c c c @} +@end example +will result in two groups of three tuplets, each group lasting for a +quarter note.") + (make-music 'TimeScaledMusic + 'element (ly:music-compress + music + (ly:make-moment (cdr ratio) (car ratio))) + 'numerator (cdr ratio) + 'denominator (car ratio) + 'duration tuplet-span)) + +tupletSpan = +#(define-music-function (parser location tuplet-span) + ((ly:duration?)) + (_i "Set @code{tupletSpannerDuration}, the length into which +@code{\\tuplet} without an explicit @samp{tuplet-span} argument of its +own will group its tuplets, to the duration @var{tuplet-span}. To +revert to the default of not subdividing the contents of a @code{\\tuplet} +command without explicit @samp{tuplet-span}, use +@example +\\tupletSpan \\default +@end example +") + (if tuplet-span + #{ \set tupletSpannerDuration = #(ly:duration-length tuplet-span) #} + #{ \unset tupletSpannerDuration #})) + tweak = #(define-music-function (parser location prop value item) (symbol-list-or-symbol? scheme? symbol-list-or-music?) -- 2.39.2